embryo_cc - fix possible buffer overrun

fix CID 1039587
This commit is contained in:
Carsten Haitzler 2014-09-01 18:53:49 +09:00
parent 1b74f19b60
commit ea3d28d0c3
1 changed files with 10 additions and 4 deletions

View File

@ -1214,10 +1214,16 @@ command(void)
char s2[20];
extern char *sc_tokens[]; /* forward declaration */
if (tok < 256)
sprintf(s2, "%c", (char)tok);
else
strcpy(s2, sc_tokens[tok - tFIRST]);
if (tok < 256)
{
s2[0] = (char)tok;
s2[1] = 0;
}
else
{
strncpy(s2, sc_tokens[tok - tFIRST], 19);
s2[19] = 0;
}
error(1, sc_tokens[tSYMBOL - tFIRST], s2);
break;
} /* case */