[hackers] [scc] [cc1] Ue tok2str() in character() || Roberto E. Vargas Caballero
commit 41b20e066ab2f220c3a6b5107a546d17fbcc891f
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Mon Jan 16 16:17:08 2017 +0100
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Mon Jan 16 16:17:08 2017 +0100
[cc1] Ue tok2str() in character()
This function handles the buffer overrun.
diff --git a/cc1/lex.c b/cc1/lex.c
index 2a0749b..dd1e902 100644
--- a/cc1/lex.c
+++ b/cc1/lex.c
_AT_@ -278,7 +278,7 @@ tok2str(void)
{
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;
}
_AT_@ -467,11 +467,9 @@ escape(void)
static unsigned
character(void)
{
- char c, *p;
+ char c;
Symbol *sym;
- size_t size;
- p = input->p;
if ((c = *++input->p) == '\\')
c = escape();
else
_AT_@ -482,14 +480,11 @@ character(void)
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;
}
Received on Mon Jan 16 2017 - 16:18:09 CET
This archive was generated by hypermail 2.3.0
: Mon Jan 16 2017 - 16:24:33 CET