fix: multiple critical bugs and safety improvements - #60
Open
hobostay wants to merge 1 commit into
Open
Conversation
Fix several bugs found across the codebase including:
1. volcuninstall.sh: Remove /dev/null from rm -rf arguments (would
destroy the system null device), add missing echo command for
error message, quote all variables in rm/path operations to
prevent word splitting issues.
2. sbd.file.c: Fix off-by-one in malloc(strlen(ptr+1)) which should
be malloc(strlen(ptr)+1). The wrong parenthesization computes
the length of the string starting one byte later, causing heap
buffer overflows at two locations.
3. lim.main.c: Add missing return after popen() NULL check to
prevent NULL pointer dereference in subsequent fgets() call.
4. bhosts.c: Fix duplicate NULL check (loadval[i] checked twice
instead of checking loadval1[i]).
5. lib.i18n.c: Replace vsprintf with vsnprintf to prevent buffer
overflow in static 1024-byte i18nPrintBuffer.
6. elock.c: Add close(lock_fd) on four error paths that were
leaking file descriptors in touchElock().
7. mbd.requeue.c: Fix realloc pattern that loses original pointer
on allocation failure, causing memory leaks in the daemon.
8. cmd.sub.c: Guard against NULL return from getenv("USER") in
error message formatting.
9. res.handler.c: Free tempBuf on XDR decode error path that was
leaking memory.
10. README.md: Fix "ByteBance" typo to "ByteDance", fix "lim
mbatchd" to "mbatchd pid" in status output example.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
chu seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
Collaborator
|
Thanks for your contribution and bug fixes! We will review these changes carefully later and get back to you :) |
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
rm -rf ... /dev/nullbug in volcuninstall.sh that would destroy the system null devicemalloc(strlen(ptr+1))(wrong parenthesization)fgets()was called afterpopen()returned NULLloadval[i]checked twice instead ofloadval1[i])vsprintfwithvsnprintfreallocfailure lost the original pointergetenv("USER")in cmd.sub.cDetails
Critical: volcuninstall.sh would destroy /dev/null
Line 111 had
/dev/nullas an argument torm -rf:This would delete
/dev/nullon Linux systems, breaking most programs. Also fixed missingechocommand on line 22 and unquoted variables in multiplerm -rfcalls.Critical: Heap buffer overflow in sbd.file.c
malloc(strlen(spooledExecName+1))computesstrlenstarting one byte after the beginning, allocating 2 bytes too few. The subsequentstrcpyoverflows the buffer. Same bug at two locations (lines 1344 and 2236).High: NULL pointer dereference in lim.main.c
After
popen()returns NULL, the code fell through tofgets(fp, ...)causing a crash. Addedreturn -1.High: File descriptor leak in elock.c
touchElock()opened a lock file but on 4 different error paths (lseek/read/write failures), returned without closing the file descriptor. In a long-running daemon this would exhaust fd limits.Medium: vsprintf buffer overflow in lib.i18n.c
vsprintfwas used with a fixed 1024-byte buffer with no bounds checking. Replaced withvsnprintf.Test plan
/dev/nullin rm commandechocommand present on error message line🤖 Generated with Claude Code