Fix 25 C audit issues (security, safety, memory)#4
Merged
farkasmark merged 1 commit intomainfrom Feb 22, 2026
Merged
Conversation
Critical: - Fix sRGB LUT data race with CAS-based init (image.c) - Fix integer overflow in cols*rows grid computation (output.c) High: - Add bounds checks on direct byte writes in ANSI output (output.c) - Add fread return value checks in tools (glif_compare, glif_verify) - Fix snprintf truncation handling with safe helper (output.c) - Fix ensure_cap/pre-alloc overflow in blip encoder (blip.c) - Fix use-after-free on audio stats after writer finish (main.c) Medium: - Replace atoi with strtol+validation in all tools - Add ftell error checks in all tools - Add malloc NULL checks in glif_codec_stats - Add pipeline return value checks in glif_compare - Guard division by zero on fps=0 (main.c) - Add negative frame check in WASM player - Check re-encode return value in writer (output.c) - Fix BLIP v1 section skip OOB read (glif.c) - Filter NaN before quickselect (contrast.c, temporal.c) Low: - Update bench.c to use current deflate codecs - Add NULL checks to blip encoder accessors - Use accessor functions for blip struct fields (output.c) - Add -Wall -Wextra to emcc builds (Makefile) - Remove unused font_size variable (font.c)
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
/c-auditacross 16 files (2 critical, 6 high, 10 medium, 7 low)Critical fixes
size_tcasts andINT_MAXbounds check oncols * rowsbefore allocationHigh fixes
freadreturn validation in tools,snprintftruncation safety via helper function, blip encoder overflow guards, use-after-free on audio statsMedium fixes
atoi→strtolwith validation in all tools,ftellerror checks,mallocNULL checks, division-by-zero guard, negative frame check in WASM player, re-encode return validation, BLIP v1 skip OOB fix, NaN filtering before quickselectLow fixes
-Wall -Wextraon emcc builds, removed dead variableTest plan
make clean && makecompiles without errorsmake test— all 185 tests pass (0 failures)