w_wad: use strnlen to check lump length for map marker
lump name may not be null terminated here, so strlen may read out of bounds garbo using strnlen ensures we read max 8 characters which is the name buffer size
This commit is contained in:
1 parent
bea274dbd8
commit
9b53a4e87f
1 file changed
+2
-1
+2
-1
@@ -2671,11 +2671,12 @@ virtres_t* vres_GetMap(lumpnum_t lumpnum)
|
||||
{
|
||||
if (vsizecache[realentry] == 0)
|
||||
continue;
|
||||
|
||||
vlumps[i].size = vsizecache[realentry];
|
||||
|
||||
const char *name = (fileinfo + realentry)->name;
|
||||
|
||||
if (strlen(name) == 5 && memcmp(name, "MAP", 3) == 0)
|
||||
if (strnlen(name, 8) == 5 && memcmp(name, "MAP", 3) == 0)
|
||||
{
|
||||
numlumps--; // We skip map marker, so 1 of entries becomes empty
|
||||
continue; // This will skip i++ so we will write to same entry
|
||||
|
||||
Reference in new issue
Block a user