From 28cfbfe880df681d0a729c8c92f01db0fd759943 Mon Sep 17 00:00:00 2001 From: Marcel Telka Date: Wed, 28 Aug 2002 09:15:12 +0000 Subject: [PATCH] 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 --- include/jtag/data_register.h | 8 +++++--- jtag/src/part/data_register.c | 10 ++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/include/jtag/data_register.h b/include/jtag/data_register.h index 61fcf2c2..71a45372 100644 --- a/include/jtag/data_register.h +++ b/include/jtag/data_register.h @@ -27,12 +27,14 @@ #include +#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; }; diff --git a/jtag/src/part/data_register.c b/jtag/src/part/data_register.c index 6824a3cb..aa3dc64d 100644 --- a/jtag/src/part/data_register.c +++ b/jtag/src/part/data_register.c @@ -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 );