Audit fixes batch 6: system() replacements, refresh_ipl fix, external script checks#141
Merged
adequatelimited merged 8 commits intomasterfrom Apr 6, 2026
Merged
Audit fixes batch 6: system() replacements, refresh_ipl fix, external script checks#141adequatelimited merged 8 commits intomasterfrom
adequatelimited merged 8 commits intomasterfrom
Conversation
Closes #114 refresh_ipl() performed two sequential read_tfile() calls into tx.buffer. The first read's output was immediately cleared and overwritten by the second, but count from the first read was used to set the packet length — making the OP_FOUND proof malformed (length from read A, buffer content from read B). Receiving peers would reject the mismatched proof, silently breaking the background peer-help mechanism. Replaced with a single read_tfile() matching send_found()'s pattern, including the NTFTX-1 offset for correct inclusive range. Added count != NTFTX check to skip the send on short/failed reads. Added TODO comment in send_found() for the same check.
…-read [F-26] fix(network): remove dead double-read in refresh_ipl() OP_FOUND proof
Closes #108 Replaced shell-spawning system() calls in syncup() and b_update() with native C equivalents using fcopy(), mkdir_p(), rename(), fappend(), and rmdir_r(). The original calls had no return-value checks, so failures (disk full, permissions, missing files) were silently ignored, potentially leaving the node with corrupted state. Changes: - syncup() backup: mkdir -p/cp -> mkdir_p()/fcopy() with error check - syncup() restore: mv/rm -> rename()/rmdir_r() with error logging - b_update() txq append: cat >> -> fappend() with error logging New files: - src/util.h/util.c: fappend() and rmdir_r() utilities, documented for future migration to the extended-c library
[F-06] fix(sync,bup): replace system() calls with native C file operations
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.
[F-12] fix(network): replace system(dd) with native C in send_tf()
Closes #109 system() calls to ../update-external.sh and ../init-external.sh had no return-value checks. A failed or erroring script was silently ignored. Added checks and pwarn() logging on non-zero return so failures are visible in the node log.
…ecks [F-20] fix(bup,sync): add return-value checks on external script system() calls
adequatelimited
added a commit
that referenced
this pull request
Apr 13, 2026
Audit fixes batch 6: system() replacements, refresh_ipl fix, external script checks
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
Sixth batch of audit remediation. Eliminates all shell-spawning
system()calls for file operations, fixes a silently broken peer-help mechanism, and adds error logging to external script hooks.Changes
[F-06] sync.c, bup.c, util.c/h — Replace
system()calls for backup/restore/append with native C usingfcopy(),mkdir_p(),rename(),fappend(),rmdir_r(). Adds error detection where none existed. Newutil.c/util.hfor functions not yet in extended-c. (Closes [F-06] HIGH: system() calls for critical state in syncup() and b_update() with no return-value checks #108)[F-12] network.c — Replace
system("dd ...")insend_tf()with nativefseek64/fread/fwrite. Removes peer-controlled values from shell command strings. AddsRunningcheck for clean shutdown. Verified with 63 offline tests and 25 live integration tests via OP_TF protocol. (Closes [F-12] MEDIUM: send_tf() invokes system("dd...") with peer-controlled skip offset — resource abuse #105)[F-26] network.c — Fix silently broken
refresh_ipl()OP_FOUND proof. Dead double-read pattern caused mismatched length/content in proof packets, so background peer-help never worked. Replaced with single read matchingsend_found(). (Closes [F-26] MEDIUM: refresh_ipl() double read_tfile — length from first read applied to buffer from second read #114)[F-20] bup.c, sync.c — Add return-value checks and
pwarn()logging on external scriptsystem()calls (update-external.sh,init-external.sh). (Closes [F-20] MEDIUM: External scripts invoked via system() with relative paths and no return-value checks #109)Testing
-Wall -Werror -Wextra -Wpedantic(GCC 13)