- Exhumed: handle unterminated strings in LoadSound without reading beyond their end.

This commit is contained in:
Christoph Oelckers 2022-01-29 13:29:38 +01:00
parent f98765ce95
commit 12b25df582

View file

@ -181,11 +181,12 @@ TArray<uint8_t> EXSoundEngine::ReadSound(int lumpnum)
int LoadSound(const char* name) int LoadSound(const char* name)
{ {
FString nname(name, 8); char nname[9]{};
int sndid = soundEngine->FindSoundNoHash(nname.GetChars()); for (int i = 0; i < 8 && name[i]; i++) nname[i] = name[i];
int sndid = soundEngine->FindSoundNoHash(nname);
if (sndid > 0) return sndid - 1; if (sndid > 0) return sndid - 1;
FStringf filename("%s.voc", nname.GetChars()); FStringf filename("%s.voc", nname);
auto lump = S_LookupSound(filename); auto lump = S_LookupSound(filename);
if (lump > 0) if (lump > 0)
{ {