Skip to content

Commit

Permalink
buffer underrun fix
Browse files Browse the repository at this point in the history
  • Loading branch information
jfdelnero committed Nov 17, 2023
1 parent 26a1521 commit a14ee2e
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions lib_jtag_core/src/script/script.c
Original file line number Diff line number Diff line change
Expand Up @@ -992,15 +992,15 @@ static int cmd_print( script_ctx * ctx, char * line)
{
genos_strndstcat((char*)str,tmp_str,sizeof(str));
genos_strndstcat((char*)str," ",sizeof(str));
str[sizeof(str) - 1] = '\0';
str[sizeof(str) - 1] = '\0';
}
else
{
ptr = getEnvVarDat( (envvar_entry *)ctx->env, &tmp_str[1], NULL, 0);
if( ptr )
{
genos_strndstcat((char*)str,ptr,sizeof(str));
genos_strndstcat((char*)str," ",sizeof(str));
genos_strndstcat((char*)str," ",sizeof(str));
}
else
{
Expand Down Expand Up @@ -1247,19 +1247,16 @@ char * arrayresize(char * array, int size, unsigned char c)
cursize++;
}

ptr[cursize*2] = '\0';

if( cursize < size )
{
while( cursize < size )
{
sprintf(&ptr[(cursize*2) + 0],"%.2X",c);
ptr[(cursize*2) + 2] = '\0';
cursize++;
}
ptr[(cursize*2) + 0] = '\0';

}
else
{
ptr[ (size * 2) - 1 ] = '\0';
}
}

Expand Down

0 comments on commit a14ee2e

Please sign in to comment.