Maximum instruction name is restricted to MAXLEN_INSTRUCTION.

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

@ -28,10 +28,12 @@
#include <jtag/register.h>
#include <jtag/data_register.h>
#define MAXLEN_INSTRUCTION 20
typedef struct instruction instruction;
struct instruction {
char *name;
char name[MAXLEN_INSTRUCTION + 1];
tap_register *value;
data_register *data_register;
instruction *next;

@ -23,6 +23,7 @@
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <jtag/instruction.h>
@ -39,11 +40,10 @@ instruction_alloc( const char *name, int len, const char *val )
if (!i)
return NULL;
i->name = strdup( name );
if (!i->name) {
free( i );
return NULL;
}
if (strlen( name ) > MAXLEN_INSTRUCTION)
printf( "Warning: Instruction too long\n" );
strncpy( i->name, name, MAXLEN_INSTRUCTION );
i->name[MAXLEN_INSTRUCTION] = '\0';
i->value = register_alloc( len );
if (!i->value) {
@ -65,7 +65,6 @@ instruction_free( instruction *i )
if (!i)
return;
free( i->name );
register_free( i->value );
free( i );
}

Loading…
Cancel
Save