]> granicus.if.org Git - postgresql/commitdiff
Fix potential memory access violation in ecpg if filename of include file is
authorMichael Meskes <meskes@postgresql.org>
Mon, 11 Mar 2019 15:11:16 +0000 (16:11 +0100)
committerMichael Meskes <meskes@postgresql.org>
Mon, 11 Mar 2019 15:26:59 +0000 (16:26 +0100)
shorter than 2 characters.

Patch by: "Wu, Fei" <wufei.fnst@cn.fujitsu.com>

src/interfaces/ecpg/preproc/pgc.l

index 3645582b43982b1fef880a40b705add152365265..cc1f0709b3fed124c5b4c5b20fa256a6d4c0e6e1 100644 (file)
@@ -1394,7 +1394,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");