diff --git a/docs/rh-log.txt b/docs/rh-log.txt index 83a3ef993..a3373ad5f 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -14,6 +14,10 @@ October 13, 2008 player's inventory when death caused the morph to revert. - Updated fmod_wrap.h for FMOD Ex 4.18. +October 10, 2008 (Changes by Graf Zahl) +- Fixed: The TEXTURES parser could copy beyond the end of a string when parsing + a 'define' definition. + October 7, 2008 (Changes by Graf Zahl) - Fixed: Cheats in demos must not access the weapon slots. - Fixed: S_ChannelEnded didn't check for a NULL SfxInfo. diff --git a/src/textures/texturemanager.cpp b/src/textures/texturemanager.cpp index 6ea67e54a..1c40c60e6 100644 --- a/src/textures/texturemanager.cpp +++ b/src/textures/texturemanager.cpp @@ -535,38 +535,43 @@ void FTextureManager::LoadTextureDefs(int wadnum, const char *lumpname) else if (sc.Compare("define")) // define a new "fake" texture { sc.GetString(); - memcpy(src, ExtractFileBase(sc.String, false), 8); - - int lumpnum = Wads.CheckNumForFullName(sc.String, true, ns_patches); - if (lumpnum == -1) lumpnum = Wads.CheckNumForFullName(sc.String, true, ns_graphics); - - sc.GetString(); - is32bit = !!sc.Compare("force32bit"); - if (!is32bit) sc.UnGet(); - - sc.GetNumber(); - width = sc.Number; - sc.GetNumber(); - height = sc.Number; - - if (lumpnum>=0) + + FString base = ExtractFileBase(sc.String, false); + if (!base.IsEmpty()) { - FTexture *newtex = FTexture::CreateTexture(lumpnum, FTexture::TEX_Override); + strncpy(src, base, 8); - if (newtex != NULL) + int lumpnum = Wads.CheckNumForFullName(sc.String, true, ns_patches); + if (lumpnum == -1) lumpnum = Wads.CheckNumForFullName(sc.String, true, ns_graphics); + + sc.GetString(); + is32bit = !!sc.Compare("force32bit"); + if (!is32bit) sc.UnGet(); + + sc.GetNumber(); + width = sc.Number; + sc.GetNumber(); + height = sc.Number; + + if (lumpnum>=0) { - // Replace the entire texture and adjust the scaling and offset factors. - newtex->bWorldPanning = true; - newtex->SetScaledSize(width, height); - memcpy(newtex->Name, src, sizeof(newtex->Name)); + FTexture *newtex = FTexture::CreateTexture(lumpnum, FTexture::TEX_Override); - FTextureID oldtex = TexMan.CheckForTexture(src, FTexture::TEX_MiscPatch); - if (oldtex.isValid()) + if (newtex != NULL) { - ReplaceTexture(oldtex, newtex, true); - newtex->UseType = FTexture::TEX_Override; + // Replace the entire texture and adjust the scaling and offset factors. + newtex->bWorldPanning = true; + newtex->SetScaledSize(width, height); + memcpy(newtex->Name, src, sizeof(newtex->Name)); + + FTextureID oldtex = TexMan.CheckForTexture(src, FTexture::TEX_MiscPatch); + if (oldtex.isValid()) + { + ReplaceTexture(oldtex, newtex, true); + newtex->UseType = FTexture::TEX_Override; + } + else AddTexture(newtex); } - else AddTexture(newtex); } } //else Printf("Unable to define hires texture '%s'\n", tex->Name);