Fix buffer overflow when linedef type 415 executes

This commit is contained in:
Gustaf Alhäll 2023-06-02 22:19:30 +02:00
parent d6d424f102
commit 8919b35b93
No known key found for this signature in database
GPG key ID: 6C1F67D690CDEDFD

View file

@ -2613,7 +2613,15 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec)
if (lumpnum == LUMPERROR || W_LumpLength(lumpnum) == 0) if (lumpnum == LUMPERROR || W_LumpLength(lumpnum) == 0)
CONS_Debug(DBG_SETUP, "Line type 415 Executor: script lump %s not found/not valid.\n", line->stringargs[0]); CONS_Debug(DBG_SETUP, "Line type 415 Executor: script lump %s not found/not valid.\n", line->stringargs[0]);
else else
COM_BufInsertText(W_CacheLumpNum(lumpnum, PU_CACHE)); {
void *lump = W_CacheLumpNum(lumpnum, PU_CACHE);
size_t len = W_LumpLength(lumpnum);
char *text = Z_Malloc(len + 1, PU_CACHE, NULL);
memcpy(text, lump, len);
text[len] = '\0';
COM_BufInsertText(text);
Z_Free(text);
}
} }
break; break;