]> git.ipfire.org Git - thirdparty/postgresql.git/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:15:09 +0000 (16:15 +0100)
shorter than 2 characters.

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

src/interfaces/ecpg/preproc/pgc.l

index 5ed185a20b6c86aad92a3d280f62a351795f83c2..deb1e554ce9326453960019862c8a0d1d03dbaa3 100644 (file)
@@ -1393,7 +1393,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");