commit 91f062f5101b968503bf034bf720cc7e7c7a2dc3
Author:     Roberto E. Vargas Caballero <[email protected]>
AuthorDate: Wed Nov 18 15:43:13 2015 +0100
Commit:     Roberto E. Vargas Caballero <[email protected]>
CommitDate: Wed Nov 18 15:43:13 2015 +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.

diff --git a/cc1/cpp.c b/cc1/cpp.c
index 72202ce..18bcd3c 100644
--- 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;

Reply via email to