From: Michael Meskes Date: Mon, 11 Mar 2019 15:11:16 +0000 (+0100) Subject: Fix potential memory access violation in ecpg if filename of include file is X-Git-Tag: REL9_6_13~55 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8cdce0a455ff885e99d672dbd8edbd217d68139f;p=postgresql Fix potential memory access violation in ecpg if filename of include file is shorter than 2 characters. Patch by: "Wu, Fei" --- diff --git a/src/interfaces/ecpg/preproc/pgc.l b/src/interfaces/ecpg/preproc/pgc.l index 3645582b43..cc1f0709b3 100644 --- a/src/interfaces/ecpg/preproc/pgc.l +++ b/src/interfaces/ecpg/preproc/pgc.l @@ -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");