fix: resolve open bugs #7, #8, #9, #11#60
Merged
mgrossmann merged 4 commits intomainfrom Apr 11, 2026
Merged
Conversation
parse_cookies() is declared as returning int but had no return statement after free(buf), causing undefined behavior. Fixes #8
Use size_t instead of int for string length calculations in httpnenv() to prevent integer overflow on long name+value pairs. Add +2 for the two null terminators that were missing from the allocation size. Reject combined lengths over 8192 bytes as a sanity limit. Fixes #7
strtok() uses internal static state that is not thread-safe. Replace all strtok() calls with manual pointer-based tokenizers: - httpshen.c: cookie parser - httpdbug.c: debug options parser - httpjes2.c: DSID and jobid list parsers - httpfile.c: SSI directive and quoted value parsers Also replace sprintf with snprintf for version string in httppars.c to prevent potential buffer overflow. Fixes #11
array_add(&httpd->httpc) in socket_thread was not synchronized with array_del in httpclos (which already uses lock/unlock). With keep-alive, connections live longer and concurrent access to the client array is more likely. Add matching lock/unlock around array_add. Fixes #9
e33aed2 to
fcd9300
Compare
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
Four open bugs fixed in separate commits:
Missing return value in parse_cookies() #8 — Missing return in parse_cookies() (httpshen.c)
Added
return 0;— was undefined behaviorInteger overflow in environment variable allocation #7 — Integer overflow in env allocation (httpnenv.c)
Use
size_tinstead ofint, add +2 for null terminators, reject combined lengths > 8192Minor fixes: strtok in SSI, version string bounds, NULL check #11 — strtok thread safety + minor fixes (5 files)
Replace all
strtok()with manual pointer-based tokenizers in httpshen.c, httpdbug.c, httpjes2.c, httpfile.c. Usesnprintfin httppars.cRace condition in client array management #9 — Race condition in client array (httpd.c)
Add
lock()/unlock()aroundarray_add(&httpd->httpc)to match the existing locking inhttpclos.cTest plan
make build && make link)?debug=cgi,vars)Fixes #7, Fixes #8, Fixes #9, Fixes #11