[F-12] fix(network): replace system(dd) with native C in send_tf()#139
Merged
adequatelimited merged 1 commit intoaudit-fixesfrom Apr 6, 2026
Merged
[F-12] fix(network): replace system(dd) with native C in send_tf()#139adequatelimited merged 1 commit intoaudit-fixesfrom
adequatelimited merged 1 commit intoaudit-fixesfrom
Conversation
2a2cd21 to
cacfa93
Compare
Closes #105 send_tf() used sprintf to construct a dd shell command with a peer-controlled skip offset, then executed it via system(). This spawned two processes per request with no error checking, and placed peer-controlled values into a shell command string. Replaced with fseek64/fread/fwrite operating directly on tfile.dat. Identical output: reads count trailers starting at offset first, writes to temp file, sends via send_file(). Handles EOF and errors explicitly.
cacfa93 to
889c0a6
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.
Closes #105
Summary
send_tf()constructed addshell command with a peer-controlled skip offset and executed it viasystem(). Replaced with nativefseek64/fread/fwrite.Change
Why
Runningflag between iterations for clean shutdownTesting
-Wall -Werror -Wextra -Wpedanticsystem(dd)and native C across normal operations, edge cases, boundary conditions, permission errors, and real tfile.dat. Posted to issue [F-12] MEDIUM: send_tf() invokes system("dd...") with peer-controlled skip offset — resource abuse #105.