Fix off-by-one check that can lead to a memory overflow in ecpg.
authorMichael Meskes <[email protected]>
Thu, 11 Apr 2019 18:56:17 +0000 (20:56 +0200)
committerMichael Meskes <[email protected]>
Thu, 11 Apr 2019 19:06:21 +0000 (21:06 +0200)
Patch by Liu Huailing <[email protected]>

src/interfaces/ecpg/preproc/pgc.l

index c388cb66ed5b6af1de7b87c4aae1679fa61b4e16..9ac68edbb8e7aa937d6f704caa715884fde065d0 100644 (file)
@@ -1376,7 +1376,7 @@ parse_include(void)
 
        for (ip = include_paths; yyin == NULL && ip != NULL; ip = ip->next)
        {
-           if (strlen(ip->path) + strlen(yytext) + 3 > MAXPGPATH)
+           if (strlen(ip->path) + strlen(yytext) + 4 > MAXPGPATH)
            {
                fprintf(stderr, _("Error: include path \"%s/%s\" is too long on line %d, skipping\n"), ip->path, yytext, yylineno);
                continue;