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

 by: "Wu, Fei" <[email protected]>

src/interfaces/ecpg/preproc/pgc.l

index 3f7a5d79998f5aaaa493533dba5378b7f4e53fd2..60474b0b4a6d5848c2b6a76d6142edefff811380 100644 (file)
@@ -1538,7 +1538,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");