Repository navigation
Fix multiple memory-safety and out-of-bounds vulnerabilities - #1209
Open
Pokimoshka wants to merge 1 commit into
Open
Pokimoshka wants to merge 1 commit into
Pokimoshka wants to merge 1 commit into
Conversation
Harden the engine, filesystem and HLTV against malformed network packets, BSP/WAD/MDL model files and demo files. Engine: - model.cpp: validate every BSP lump offset/size against the file size and add planenum/texinfo/children/marksurface/visofs bounds checks in Mod_LoadFaces/Nodes/Leafs - l_studio.cpp: validate .mdl header (length/numtextures/texture indices) and per-texture sizes against the actual file size - wad.cpp: validate WAD header and lump table against the file size - delta.cpp: bound DT_STRING writes to the destination structure - hashpak.cpp: validate nFileLength against MAX_FILE_SIZE; fix MD5 computed over the wrong file handle - host_cmd.cpp: validate save-game header fields and lightstyle indices; fix FileCopy size argument; use Q_vsnprintf - common.cpp: guard MSG_ReadBitString and SZ_Print against OOB - cvar.cpp: bound printable-char copy in Cvar_DirectSet - decals.cpp: reject oversized custom logos - pr_cmds.cpp: guard entnum in PF_SetPhysicsKeyValue - filesystem.cpp/filesystem_internal.cpp: use bounded string copies - sv_remoteaccess.cpp: pass buffer sizes to CUtlBuffer::GetString - mem.cpp: NULL-check malloc result in Mem_ZeroMalloc - cmd.cpp: bound com_argv access in Cmd_StuffCmds_f Filesystem: - BaseFileSystem.cpp: NULL-check GetWritePath callers, init struct _stat, guard StripFilename/FixPath on empty strings, fix FullPathToRelativePath - linux_support.cpp: fix scandir namelist handling HLTV: - World.cpp: bound entities and baseline offset in UncompressEntitiesFromStream (both overloads) - BSPModel.cpp: validate lumps/indices, cap numleafs, fix PVS buffer off-by-one - DemoPlayer.cpp: NUL-terminate StringCmd buffer; validate demo sample sizes - NetChannel.cpp: validate bzip2 size and return value - BitBuffer.cpp/Delta.cpp: bound ReadBitString and DT_STRING - DemoFile.cpp: validate demo packet length - Proxy.cpp: enlarge connectionless buffer and init outputbuf Common: - ObjectDictionary.cpp: fix FindClosestAsIndex/RemoveIndexRange/RemoveKey OOB and memmove - commandline.cpp: enable bounds checks in LoadParametersFromFile - netapi.cpp/parsemsg.cpp: bounded copies and READ_FLOAT bounds check
Pokimoshka
force-pushed
the
pr/security-fixes
branch
from
November 4, 2026 16:48
be3e96c to
96c7cce
Compare
This was referenced Nov 8, 2026
mrc4tt
added a commit
to mrc4tt/ReHLDS
that referenced
this pull request
Nov 8, 2026
security: upstream rehlds#1209 (memory-safety / OOB hardening)
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR hardens the engine, filesystem and HLTV against malformed network packets, BSP/WAD/MDL model files and demo files. It is a collection of bounds/validation fixes found during a security audit.
Engine
planenum/texinfo/children/marksurface/visofsbounds checks inMod_LoadFaces/Mod_LoadNodes/Mod_LoadLeafs..mdlheader (length/numtextures/textureindices) and per-texture sizes against the real file size (prevents heap overflow viaheight * widthand OOBmemcpy).DT_STRINGwrites to the destination structure.nFileLengthagainstMAX_FILE_SIZE; fix the MD5 being computed over the wrong file handle.FileCopysize argument; useQ_vsnprintf.MSG_ReadBitStringandSZ_Printagainst OOB.Cvar_DirectSet.entnuminPF_SetPhysicsKeyValue.CUtlBuffer::GetString.mallocresult inMem_ZeroMalloc.com_argvaccess inCmd_StuffCmds_f.Filesystem
GetWritePathcallers, zero-initializestruct _stat, guardStripFilename/FixPathon empty strings, fixFullPathToRelativePathreturningfalseon success.scandirnamelist handling.HLTV
UncompressEntitiesFromStream(both overloads) — fixes a heap overflow inframeCache_t::entitiesand a negative-index baseline read.numleafs, fix the PVS buffer off-by-one.StringCmdbuffer; validate demo sample sizes.ReadBitStringandDT_STRING.outputbuf.Common
FindClosestAsIndex/RemoveIndexRange/RemoveKeyand usememmove.LoadParametersFromFile.READ_FLOATbounds check.