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-Url: http://git.postgresql.org/gitweb/-?a=commitdiff_plain;h=08cecfaf60c484f219ba7e6ee23e9699aea4e9af;p=users%2Frhaas%2Fpostgres.git 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 3f7a5d7999..60474b0b4a 100644 --- a/src/interfaces/ecpg/preproc/pgc.l +++ b/src/interfaces/ecpg/preproc/pgc.l @@ -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");