From 7c83e5e420fb91ddde3c464e667b2474d3b02f2f Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Fri, 31 Jan 2020 16:37:55 -0500 Subject: [PATCH 1/3] Implement folder blacklisting --- src/w_wad.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/w_wad.c b/src/w_wad.c index dc400987f..b0c901302 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -1746,6 +1746,18 @@ W_VerifyWAD (FILE *fp, lumpchecklist_t *checklist, boolean status) return true; } +// List of blacklisted folders to use when checking the PK3 +static lumpchecklist_t folderblacklist[] = +{ + {"Lua/", 4}, + {"SOC/", 4}, + {"Sprites/", 8}, + {"Textures/", 9}, + {"Patches/", 8}, + {"Flats/", 6}, + {"Fades/", 6} +}; + static int W_VerifyPK3 (FILE *fp, lumpchecklist_t *checklist, boolean status) { @@ -1791,6 +1803,13 @@ W_VerifyPK3 (FILE *fp, lumpchecklist_t *checklist, boolean status) if (fgets(fullname, zentry.namelen + 1, fp) != fullname) return true; + // Check for folders first, if it's blacklisted it will return false + if (W_VerifyName(fullname, folderblacklist, status)) + { + CONS_Printf("Blacklisted folder found - %s\n", fullname); + return false; + } + // Strip away file address and extension for the 8char name. if ((trimname = strrchr(fullname, '/')) != 0) trimname++; From a2c15c5cb2c9d070e5a20420d8c45fd1db0c1832 Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Fri, 31 Jan 2020 20:21:09 -0500 Subject: [PATCH 2/3] Only check if the directory is not empty, use strncasecmp for case insensitive comparing, and remove debug print --- src/w_wad.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/w_wad.c b/src/w_wad.c index b0c901302..12d912c92 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -1691,7 +1691,7 @@ W_VerifyName (const char *name, lumpchecklist_t *checklist, boolean status) size_t j; for (j = 0; checklist[j].len && checklist[j].name; ++j) { - if (( strncmp(name, checklist[j].name, + if (( strncasecmp(name, checklist[j].name, checklist[j].len) != false ) == status) { return true; @@ -1803,20 +1803,13 @@ W_VerifyPK3 (FILE *fp, lumpchecklist_t *checklist, boolean status) if (fgets(fullname, zentry.namelen + 1, fp) != fullname) return true; - // Check for folders first, if it's blacklisted it will return false - if (W_VerifyName(fullname, folderblacklist, status)) - { - CONS_Printf("Blacklisted folder found - %s\n", fullname); - return false; - } - // Strip away file address and extension for the 8char name. if ((trimname = strrchr(fullname, '/')) != 0) trimname++; else trimname = fullname; // Care taken for root files. - if (*trimname) // Ignore directories + if (*trimname) // Ignore directories, well kinda { if ((dotpos = strrchr(trimname, '.')) == 0) dotpos = fullname + strlen(fullname); // Watch for files without extension. @@ -1826,6 +1819,10 @@ W_VerifyPK3 (FILE *fp, lumpchecklist_t *checklist, boolean status) if (! W_VerifyName(lumpname, checklist, status)) return false; + + // Check for directories next, if it's blacklisted it will return false + if (W_VerifyName(fullname, folderblacklist, status)) + return false; } free(fullname); From 17949496964e850128a562d0dc57b5f484b87556 Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Sun, 2 Feb 2020 18:52:41 -0500 Subject: [PATCH 3/3] Add empty entry --- src/w_wad.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/w_wad.c b/src/w_wad.c index 12d912c92..c9426b46c 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -1755,7 +1755,8 @@ static lumpchecklist_t folderblacklist[] = {"Textures/", 9}, {"Patches/", 8}, {"Flats/", 6}, - {"Fades/", 6} + {"Fades/", 6}, + {NULL, 0}, }; static int