scc

Simple C99 Compiler
Log | Files | Refs | README | LICENSE

commit 91f062f5101b968503bf034bf720cc7e7c7a2dc3
parent 5248a9060ab850caff27bdefc8faf609ffe4f2c5
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Wed, 18 Nov 2015 15:43:13 +0100

Do not allow empty file names in include directives

If the file name of a include directive is empty, fread
will try to read it, and even in some systems will return data,
because it will read data from the directory, so we have to
detect this condition and emit a diagnose.

Diffstat:
cc1/cpp.c | 4++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/cc1/cpp.c b/cc1/cpp.c @@ -471,7 +471,7 @@ include(void) switch (*yytext) { case '<': - if ((p = strchr(input->begin, '>')) == NULL) + if ((p = strchr(input->begin, '>')) == NULL || p == yytext + 1) goto bad_include; *p = '\0'; file = input->begin; @@ -479,7 +479,7 @@ include(void) input->begin = input->p = p+1; break; case '"': - if ((p = strchr(yytext + 1, '"')) == NULL) + if ((p = strchr(yytext + 1, '"')) == NULL || p == yytext + 1) goto bad_include; *p = '\0'; file = yytext+1;