Maximum length of the data register name is restricted to MAXLEN_DATA_REGISTER.

git-svn-id: https://urjtag.svn.sourceforge.net/svnroot/urjtag/trunk@128 b68d4a1b-bc3d-0410-92ed-d4ac073336b7
master
Marcel Telka 23 years ago
parent c76b7b31ce
commit 28cfbfe880

@ -27,12 +27,14 @@
#include <jtag/register.h>
#define MAXLEN_DATA_REGISTER 10
typedef struct data_register data_register;
struct data_register {
char *name; /* (public) register name */
tap_register *in; /* (public) register value clocked in */
tap_register *out; /* (public) register value clocked out */
char name[MAXLEN_DATA_REGISTER + 1]; /* (public) register name */
tap_register *in; /* (public) register value clocked in */
tap_register *out; /* (public) register value clocked out */
data_register *next;
};

@ -39,11 +39,10 @@ data_register_alloc( const char *name, int len )
if (!dr)
return NULL;
dr->name = strdup( name );
if (!dr->name) {
free( dr );
return NULL;
}
if (strlen( name ) > MAXLEN_DATA_REGISTER)
printf( "Warning: Data register too long\n" );
strncpy( dr->name, name, MAXLEN_DATA_REGISTER );
dr->name[MAXLEN_DATA_REGISTER] = '\0';
dr->in = register_alloc( len );
dr->out = register_alloc( len );
@ -66,7 +65,6 @@ data_register_free( data_register *dr )
if (!dr)
return;
free( dr->name );
register_free( dr->in );
register_free( dr->out );
free( dr );

Loading…
Cancel
Save