ref: 47846316bb2f9c8dfdde56b31021f2e9cf12bcbb
parent: 57daf2b20c49488d3d5771239ee302a0afb6004a
author: Roberto E. Vargas Caballero <[email protected]>
date: Mon Jan 16 11:17:08 EST 2017
[cc1] Ue tok2str() in character() This function handles the buffer overrun.
--- a/cc1/lex.c
+++ b/cc1/lex.c
@@ -278,7 +278,7 @@
{
if ((yylen = input->p - input->begin) > INTIDENTSIZ)
error("token too big");
- strncpy(yytext, input->begin, yylen);
+ memcpy(yytext, input->begin, yylen);
yytext[yylen] = '\0';
input->begin = input->p;
}
@@ -467,11 +467,9 @@
static unsigned
character(void)
{
- char c, *p;
+ char c;
Symbol *sym;
- size_t size;
- p = input->p;
if ((c = *++input->p) == '\\')
c = escape();
else
@@ -482,14 +480,11 @@
else
++input->p;
- size = input->p - p;
- memcpy(yytext, p, size);
- yytext[size] = '\0';
-
sym = newsym(NS_IDEN, NULL);
sym->u.i = c;
sym->type = inttype;
yylval.sym = sym;
+ tok2str();
return CONSTANT;
}