Fix potential buffer overrun in #emit and __emit
This commit is contained in:
parent
62779691ab
commit
4b490e8ec2
@ -6948,13 +6948,13 @@ SC_FUNC void emit_parse_line(void)
|
||||
* and copy the instruction name
|
||||
*/
|
||||
lptr-=len;
|
||||
for (i=0; i<sizeof(name) && (isalnum(*lptr) || *lptr=='.'); ++i,++lptr)
|
||||
for (i=0; i<sizeof(name)-1 && (isalnum(*lptr) || *lptr=='.'); ++i,++lptr)
|
||||
name[i]=(char)tolower(*lptr);
|
||||
name[i]='\0';
|
||||
|
||||
/* find the corresponding argument handler and call it */
|
||||
i=emit_findopcode(name,strlen(name));
|
||||
if (emit_opcodelist[i].name==NULL && *name!='\0')
|
||||
i=emit_findopcode(name,i);
|
||||
if (emit_opcodelist[i].name==NULL && name[0]!='\0')
|
||||
error(104,name); /* invalid assembler instruction */
|
||||
emit_opcodelist[i].func(name);
|
||||
} else if (tok==tLABEL) {
|
||||
|
@ -1337,12 +1337,12 @@ static int command(void)
|
||||
case tpEMIT: {
|
||||
if (!SKIPPING) {
|
||||
/* write opcode to output file */
|
||||
char name[40];
|
||||
char name[MAX_INSTR_LEN];
|
||||
int i;
|
||||
insert_dbgline(fline);
|
||||
while (*lptr<=' ' && *lptr!='\0')
|
||||
lptr++;
|
||||
for (i=0; i<40 && (isalpha(*lptr) || *lptr=='.'); i++,lptr++)
|
||||
for (i=0; i<sizeof(name)-1 && (isalpha(*lptr) || *lptr=='.'); i++,lptr++)
|
||||
name[i]=(char)tolower(*lptr);
|
||||
name[i]='\0';
|
||||
stgwrite("\t");
|
||||
|
Loading…
x
Reference in New Issue
Block a user