[hackers] [scc] Do not allow empty file names in include directives || Roberto E. Vargas Caballero

From: <git_AT_suckless.org>
Date: Mon, 23 Nov 2015 16:58:40 +0100 (CET)

commit 91f062f5101b968503bf034bf720cc7e7c7a2dc3
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Wed Nov 18 15:43:13 2015 +0100
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
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
_AT_@ -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;
_AT_@ -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;
Received on Mon Nov 23 2015 - 16:58:40 CET

This archive was generated by hypermail 2.3.0 : Mon Nov 23 2015 - 17:00:18 CET