aboutsummaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* ash: allow wait to handle more than 64 processeswaitforRon Yorston2026-07-161-1/+12
| | | | | | | | | | | | | | | | | | | WaitForMultipleObjects() can only handle 64 processes (actually, MAXIMUM_WAIT_OBJECTS) in a single call. Using the 'wait' shell built-in after a command like: for i in $(seq 1 70); do echo $i; sleep 10 & done resulted in an uninterruptible 'wait'. Handle processes in batches of MAXIMUM_WAIT_OBJECTS. The problem was noted by Morgan Bartlett, who also supplied a fix which I claim to have 'improved'. Adds 32-48 bytes. Signed-off-by: Ron Yorston <rmy@pobox.com>
* xargs: limit number of processes to 64Ron Yorston2026-07-161-18/+4
| | | | | | | | | | | | | | | | Upstream limits the number of processes invoked with the '-P 0' option to 100. On Windows the limit was set to MAXIMUM_WAIT_OBJECTS, as that's the most WaitForMultipleObjects() can handle. Apply the same limit to user-supplied '-P' values. This avoids the need to loop over blocks of MAXIMUM_WAIT_OBJECTS. "64 processes ought to be enough for anyone." Saves 64-80 bytes. Signed-off-by: Ron Yorston <rmy@pobox.com>
* win32: code shrink procps_scan()Ron Yorston2026-07-153-28/+29
| | | | | | | | | | | | | The principal change is to replace four separate arrays (one for pids and three for time values) with a single array of structs. There are some other minor adjustments. Saves 96-144 bytes. (GitHub PR #609) Signed-off-by: Ron Yorston <rmy@pobox.com>
* fix: procps_scan: do not confirm a process to be parent if either creation ↵Shun Zi2026-07-151-4/+4
| | | | time is unknown.
* fix: procps_scan: compare process creation times to ensure ppid is realshunf42026-07-153-16/+55
| | | | | | | | | | | | | | Windows aggressively reuses PIDs of exited processes. When a new irrelevant process gets assigned the former PID of the parent of an orphaned process, `pkill -P`, `pgrep -P`, `ps -o ppid` sees the new process as the parent of the orphaned process, and PPID of the orphan is no longer 1. So in theory, all `pkill -P`, `pgrep -P` calls are potentially dangerous and possible to kill an innocent process which outlives its parent. This issue is already discussed in various Internet communities: - https://stackoverflow.com/questions/6593003/how-can-i-reliably-check-whether-one-windows-process-is-the-parent-of-another-in - https://web.archive.org/web/20140701081232/https://www.sapphiresteel.com/Blog/Killing-Trees-the-Windows-way Comparing process creation times seems a feasible mitigation that should almost always work (though not theoretically sound). The executable is added 512 bytes after the patch.
* win32: workaround for overflow of 8.3 short name (2)Ron Yorston2026-07-141-1/+1
| | | | | | | | | | | | Replace a call to 'FindNextFileA()' in 'get_reparse_tag()'. This has no effect on the standard builds. Builds with the UTF-8 manifest included save 4-8 bytes as this removes the only remaining call to 'FindNextFileA()'. (GitHub issue #506) Signed-off-by: Ron Yorston <rmy@pobox.com>
* win32: workaround for overflow of 8.3 short nameRon Yorston2026-07-133-2/+36
| | | | | | | | | | | | | | | | | | | | | | | In certain circumstances 'FindNextFileA()' can fail because the legacy DOS 8.3 short name doesn't fit in the buffer supplied. This can be avoided by using 'FindFirstFileExA()' instead, but with a setting that isn't available on Windows XP. - The problem doesn't arise in the standard 32 and 64 bit builds, so no change is required. - Builds with full Unicode support target platforms which have the required setting. They can use 'FindFirstFileExA()' unconditionally, at the cost of 36-56 bytes. - Builds which include the UTF-8 manifest but which are allowed to run on systems prior to Windows 10 need to check whether they need to call 'FindFirstFileExA()' at runtime. This adds 100 bytes. (GitHub issue #506) Signed-off-by: Ron Yorston <rmy@pobox.com>
* xxd: allow '-p -c 0' to cause a single line to be outputRon Yorston2026-07-132-2/+26
| | | | | | | | | | | | | | | | Since 2022 the 'xxd' which comes with 'vim' has allowed the combination of options '-p -c 0' as a way to request output on a single line. Details: https://github.com/vim/vim/pull/9524 Add this feature to the BusyBox 'xxd' applet. Adds 64 bytes. (GitHub issue #610) Signed-off-by: Ron Yorston <rmy@pobox.com>
* Merge branch 'busybox' into mergeRon Yorston2026-07-0830-333/+642
|\ | | | | | | Signed-off-by: Ron Yorston <rmy@pobox.com>
| * join: code shrink by making some variables "global"Denys Vlasenko2026-07-081-50/+58
| | | | | | | | | | | | | | | | | | | | | | function old new delta readfields 442 437 -5 printfields 462 457 -5 join_main 843 760 -83 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/3 up/down: 0/-93) Total: -93 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * join: new appletRon Yorston2026-07-082-0/+595
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | function old new delta join_main - 843 +843 printfields - 462 +462 readfields - 442 +442 .rodata 107120 107332 +212 packed_usage 36078 36237 +159 applet_names 2870 2875 +5 applet_main 1652 1656 +4 ------------------------------------------------------------------------------ (add/remove: 4/0 grow/shrink: 4/0 up/down: 2127/0) Total: 2127 bytes text data bss dec hex filename 1080964 555 4992 1086511 10942f busybox_old 1083091 555 4992 1088638 109c7e busybox_unstripped v2: Add a missing return statement which broke the '-t' option. Thanks to Roberto A. Foglietta for pointing this out. Signed-off-by: Morgan Bartlett <mjmouse9999@gmail.com> Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: fix out-of-bounds read in ifsbreakup()Sanghyun Park2026-07-061-9/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ifsfree() does not only release allocated ifsregion nodes; it also clears the global IFS region state used by ifsbreakup(). If argstr() raises an error while expanding an argument, ash longjmps out of expandarg() before that cleanup runs, leaving stale IFS split offsets behind. A later expansion can reuse the stack for a shorter string. ifsbreakup() then sees the stale IFS state, trusts the old offsets, and can walk past the current stack block before dereferencing p. Follow dash's root-cause fix: when an expansion-related handler catches EXERROR and continues, restore the handler and call ifsfree(). Apply the cleanup to redirectsafe(), expandstr(), and evaltree(). Upstream commit: Date: Mon Dec 5 23:02:01 2022 +0800 expand: Add ifsfree to expand to fix a logic error that causes a buffer over-read On Mon, Jun 20, 2022 at 02:27:10PM -0400, Alex Gorinson wrote: > Due to a logic error in the ifsbreakup function in expand.c if a > heredoc and normal command is run one after the other by means of a > semi-colon, when the second command drops into ifsbreakup the command > will be evaluated with the ifslastp/ifsfirst struct that was set when > the here doc was evaluated. This results in a buffer over-read that > can leak the program's heap, stack, and arena addresses which can be > used to beat ASLR. > > Steps to Reproduce: > First bug: > cmd args: ~/exampleDir/example> dash > $ M='AAAAAAAAAAAAAAAAA' <note: 17 A's> > $ q00(){ > $ <<000;echo > $ ${D?$M$M$M$M$M$M} <note: 6 $M's> > $ 000 > $ } > $ q00 <note: After the q00 is typed in, the leak > should be echo'd out; this works with ash, busybox ash, and dash and > with all option args.> > > Patch: > Adding the following to expand.c will fix both bugs in one go. > (Thank you to Harald van Dijk and Michael Greenberg for doing the > heavy lifting for this patch!) > ========================== > --- a/src/expand.c > +++ b/src/expand.c > @@ -859,6 +859,7 @@ > if (discard) > return -1; > > +ifsfree(); > sh_error("Bad substitution"); > } > > @@ -1739,6 +1740,7 @@ > } else > msg = umsg; > } > +ifsfree(); > sh_error("%.*s: %s%s", end - var - 1, var, msg, tail); > } > ========================== Thanks for the report! I think it's better to add the ifsfree() call to the exception handling path as other sh_error calls may trigger this too. function old new delta restore_handler_expandarg - 33 +33 evaltree 725 711 -14 static.redirectsafe 141 124 -17 expandstr 262 242 -20 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 0/3 up/down: 36/-45) Total: -18 bytes Signed-off-by: Sanghyun Park <sanghyun.park.cnu@gmail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * awk: fix printf "%o\n", -1Denys Vlasenko2026-07-062-5/+7
| | | | | | | | | | | | | | function old new delta awk_printf 1381 1387 +6 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * svlogd: fix buffer overrunDenys Vlasenko2026-07-031-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Patch by mjmouse9999@gmail.com When running svlogd -tt with a long line of input, the code assumes a buffer of at least linemax+26 length, but that is two bytes longer than the actual buffer with the default of linemax = 1000. fixing that. No code size change. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * cmp: add KMG suffix for cmp -n MAXCOUNTAnubhav Kokane2026-07-032-6/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Change input to getopt32 from int to char * so that max_count is parsed as string. Use xatol_sfx to convert string to long. function old new delta cmp_main 595 631 +36 .rodata 107121 107120 -1 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/1 up/down: 36/-1) Total: 35 bytes Signed-off-by: Anubhav Kokane <dev.anubhavk@gmail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * awk: optimize 'print "no format specs here\n"' caseDenys Vlasenko2026-07-021-20/+26
| | | | | | | | | | | | | | function old new delta awk_printf 1349 1381 +32 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * awk: fix printing of very large numbers with printf("%d")Denys Vlasenko2026-07-022-89/+179
| | | | | | | | | | | | | | | | | | | | function old new delta awk_printf 1086 1349 +263 .rodata 107108 107121 +13 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/0 up/down: 276/0) Total: 276 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * awk: rename variables in awk_printf(), no code changesDenys Vlasenko2026-07-021-34/+36
| | | | | | | | | | | | | | awk_printf() got bigger, and now variables need better names, even if this makes them longer. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * awk: add '*' as a valid specifier for width and precision in printfDenys Vlasenko2026-07-012-9/+111
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Based on a patch by Anubhav Kokane <dev.anubhavk@gmail.com> function old new delta awk_printf 640 1086 +446 .rodata 107131 107108 -23 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/1 up/down: 446/-23) Total: 423 bytes text data bss dec hex filename 1080210 555 4992 1085757 10913d busybox_old 1080633 555 4992 1086180 1092e4 busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * testing stripts: allow to skip "awk gsub erroneous word start match" testDenys Vlasenko2026-05-143-6/+11
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * hush: placate warning: 'print_pfx_escaped_nl' defined but not usedDenys Vlasenko2026-05-141-0/+2
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * tls: use bb_simple_error_msg where appropriateDenys Vlasenko2026-05-141-2/+2
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * Start 1.39.0 development cycleDenys Vlasenko2026-05-131-2/+2
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * Bump version to 1.38.0Denys Vlasenko2026-05-131-1/+1
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * Optimize !ENABLE_SHOW_USAGE configDenys Vlasenko2026-05-022-42/+46
| | | | | | | | | | | | | | function old new delta bb_show_usage 6 - -6 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * cpio.tests: fix false positiveDenys Vlasenko2026-04-301-1/+3
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * cpio.tests: do not use "ls" to detect that file does not existDenys Vlasenko2026-04-301-2/+2
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * tar: unicode fixDenys Vlasenko2026-04-302-1/+5
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * cpio.tests: fix false positive when -o support is not enabledDenys Vlasenko2026-04-301-1/+1
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * cpio: fix a bug (wrong free() address) in !FEATURE_TAR_LONG_OPTIONS configDenys Vlasenko2026-04-302-1/+5
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * start-stop-daemon.tests: fix false positive if longopts are not enabledDenys Vlasenko2026-04-292-0/+7
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * Fix "undefined reference to 'skip_unsafe_prefix' build failureDenys Vlasenko2026-04-292-4/+4
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * fdisk: fix build failure on glibcDenys Vlasenko2026-04-291-1/+3
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * Fix randomtest to not select TC on glibcDenys Vlasenko2026-04-291-4/+2
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * httpd: fix build for !FEATURE_HTTPD_CGI configDenys Vlasenko2026-04-291-2/+2
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * Fix randomtest to never select a debug configDenys Vlasenko2026-04-291-0/+6
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * telnet: fix build for !TELNETD configDenys Vlasenko2026-04-291-0/+1
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * httpd: fix build for !FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR configDenys Vlasenko2026-04-291-1/+1
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * hush: fix build for !HUSH_CASE configDenys Vlasenko2026-04-291-4/+4
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * libbb: rename two fields in ioloop_state, no logic changesDenys Vlasenko2026-04-124-44/+44
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * trylink: remove "local" bashismDenys Vlasenko2026-03-161-8/+3
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * trylink: detect linker flag support for non-GNU linkersChristian Stewart2026-03-151-1/+27
| | | | | | | | | | | | | | | | | | | | wasm-ld does not support --start-group/--end-group, --warn-common, --verbose, or -Map flags. Add check_cc tests so these are only used when the linker supports them, following the existing --sort-section and --sort-common patterns. Signed-off-by: Christian Stewart <christian@aperture.us> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * less: fix ":d" commandDenys Vlasenko2026-03-151-13/+13
| | | | | | | | | | | | | | function old new delta less_main 2105 2062 -43 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * runsv: fix open error check (fd < -1 should be fd < 0)Denys Vlasenko2026-03-131-1/+1
| | | | | | | | | | | | | | | | | | From: Weixie Cui <cuiweixie@gmail.com> function old new delta update_status 608 607 -1 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * udhcpc6: check the size of D6_OPT_IAPREFIX optionDenys Vlasenko2026-03-121-2/+5
| | | | | | | | | | | | | | function old new delta option_to_env 694 711 +17 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * udhcpc6: fix buffer overflowDenys Vlasenko2026-03-121-3/+3
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | make: fix build with FEATURE_CLEAN_UP enabledRon Yorston2026-07-061-0/+1
| | | | | | | | | | | | | | | | | | The 'make' applet failed to build with FEATURE_CLEAN_UP enabled. Add an early declaration of freerules() to avoid this. This doesn't affect the default builds. Signed-off-by: Ron Yorston <rmy@pobox.com>
* | join: re-add accidentally removed returnmbartlett212026-07-062-0/+7
| | | | | | | | It broke single-character splitting
* | join: code shrink (5)Ron Yorston2026-07-051-10/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Add a freelines() function to free the line data associated with an FDAT struct. This has no effect in the default build but saves 48-64 bytes if FEATURE_CLEAN_UP is enabled. Change the type of the 'first' flag in readfields() to be consistent with that in printfields(). The 'lines' array should be freed for each FDAT struct during clean up, as it was before I broke it. Signed-off-by: Ron Yorston <rmy@pobox.com>
* | join: changesmbartlett212026-07-052-38/+39
| | | | | | | | | | | | | | | | | | | | | | Fix combinatorial field_split() now takes in LINE as a parameter, rather than just the fields parameter. Saves 16 bytes. Signed-off-by: Ron Yorston <rmy@pobox.com>