Fix potential memory access violation in ecpg if filename of include file is
authorMichael Meskes
Mon, 11 Mar 2019 15:11:16 +0000 (16:11 +0100)
committerMichael Meskes
Mon, 11 Mar 2019 15:14:03 +0000 (16:14 +0100)
shorter than 2 characters.

Patch by: "Wu, Fei" 

src/interfaces/ecpg/preproc/pgc.l

index 0792118cfe3f8921de60456cec302463bb0ec19e..56682067aff4ec4c7539fb32afcd45418520e288 100644 (file)
@@ -1396,7 +1396,7 @@ parse_include(void)
        yyin = fopen(inc_file, "r");
        if (!yyin)
        {
-           if (strcmp(inc_file + strlen(inc_file) - 2, ".h") != 0)
+           if (strlen(inc_file) <= 2 || strcmp(inc_file + strlen(inc_file) - 2, ".h") != 0)
            {
                strcat(inc_file, ".h");
                yyin = fopen(inc_file, "r");