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
|
* and copy the instruction name
|
||||||
*/
|
*/
|
||||||
lptr-=len;
|
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]=(char)tolower(*lptr);
|
||||||
name[i]='\0';
|
name[i]='\0';
|
||||||
|
|
||||||
/* find the corresponding argument handler and call it */
|
/* find the corresponding argument handler and call it */
|
||||||
i=emit_findopcode(name,strlen(name));
|
i=emit_findopcode(name,i);
|
||||||
if (emit_opcodelist[i].name==NULL && *name!='\0')
|
if (emit_opcodelist[i].name==NULL && name[0]!='\0')
|
||||||
error(104,name); /* invalid assembler instruction */
|
error(104,name); /* invalid assembler instruction */
|
||||||
emit_opcodelist[i].func(name);
|
emit_opcodelist[i].func(name);
|
||||||
} else if (tok==tLABEL) {
|
} else if (tok==tLABEL) {
|
||||||
|
@ -1337,12 +1337,12 @@ static int command(void)
|
|||||||
case tpEMIT: {
|
case tpEMIT: {
|
||||||
if (!SKIPPING) {
|
if (!SKIPPING) {
|
||||||
/* write opcode to output file */
|
/* write opcode to output file */
|
||||||
char name[40];
|
char name[MAX_INSTR_LEN];
|
||||||
int i;
|
int i;
|
||||||
insert_dbgline(fline);
|
insert_dbgline(fline);
|
||||||
while (*lptr<=' ' && *lptr!='\0')
|
while (*lptr<=' ' && *lptr!='\0')
|
||||||
lptr++;
|
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]=(char)tolower(*lptr);
|
||||||
name[i]='\0';
|
name[i]='\0';
|
||||||
stgwrite("\t");
|
stgwrite("\t");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user