fix: replace sprintf with snprintf to prevent buffer overflows in q3map2#256
Closed
tombudd wants to merge 1 commit intogoogle-deepmind:masterfrom
Closed
fix: replace sprintf with snprintf to prevent buffer overflows in q3map2#256tombudd wants to merge 1 commit intogoogle-deepmind:masterfrom
tombudd wants to merge 1 commit intogoogle-deepmind:masterfrom
Conversation
Convert 11 bare sprintf() calls to snprintf() with sizeof(dest) across the q3map2 map compilation toolchain: - bsp.c: 5 calls writing to fixed 1024-byte buffers (out, path, shader) using user-supplied source paths from command-line arguments - path_init.c: 2 calls concatenating home/base/game paths into MAX_OS_PATH (4096) buffers — long paths could overflow - vis.c: 2 calls writing expanded argv arguments into global source and portalfile buffers - convert_ase.c: 1 call writing formatted material names - bspfile_abstract.c: 1 call writing temp filenames with timestamps All replacements are mechanical sprintf → snprintf with sizeof(dest), preserving exact formatting and behavior on success paths. Reviewed-by: UNA-GDO sovereign-v2.0 (Autonomous Security Auditor) Built-by: Tom Budd <tom@tombudd.com> — tombudd.com
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
Collaborator
|
These are bugs in the upstream ioq3 code, right? We should fix them there, and then pull in an update of the base here. |
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.
Summary
Convert 11 bare
sprintf()calls tosnprintf()withsizeof(dest)across the q3map2 map compilation toolchain to prevent buffer overflow vulnerabilities. Found by UNA (autonomous security auditor, designed and built by Tom Budd — tom@tombudd.com).The Problem
The q3map2 toolchain uses
sprintf()extensively to format strings into fixed-size buffers. Several of these accept user-controlled input (command-line file paths viaExpandArg(argv[])) that can exceed the destination buffer size, causing stack-based buffer overflows.Files Changed
bsp.cout,path,shaderbufferspath_init.cMAX_OS_PATH(4096) buffersvis.csourceandportalfilebuffersconvert_ase.cbspfile_abstract.cTotal: 5 files, +11 / -11 lines (mechanical 1:1 replacements)
Why
snprintfEvery replacement is
sprintf(buf, fmt, ...) → snprintf(buf, sizeof(buf), fmt, ...). This:About This Review
This security audit was performed by UNA (Unified Nexus Agent), an autonomous AI security auditor — a Governed Digital Organism (GDO) designed and built by Tom Budd (tom@tombudd.com | tombudd.com).