| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
| |
|
|
| |
time is unknown.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
|
|
|
|
|
| |
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>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
| |\
| |
| |
| | |
Signed-off-by: Ron Yorston <rmy@pobox.com>
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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>
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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>
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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>
|
| | |
| |
| |
| |
| |
| |
| | |
function old new delta
awk_printf 1381 1387 +6
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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>
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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>
|
| | |
| |
| |
| |
| |
| |
| | |
function old new delta
awk_printf 1349 1381 +32
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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_printf() got bigger, and now variables need better names,
even if this makes them longer.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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>
|
| | |
| |
| |
| | |
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| | |
| |
| |
| | |
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| | |
| |
| |
| | |
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| | |
| |
| |
| | |
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| | |
| |
| |
| | |
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| | |
| |
| |
| |
| |
| |
| | |
function old new delta
bb_show_usage 6 - -6
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| | |
| |
| |
| | |
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| | |
| |
| |
| | |
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| | |
| |
| |
| | |
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| | |
| |
| |
| | |
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| | |
| |
| |
| | |
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| | |
| |
| |
| | |
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| | |
| |
| |
| | |
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| | |
| |
| |
| | |
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| | |
| |
| |
| | |
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| | |
| |
| |
| | |
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| | |
| |
| |
| | |
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| | |
| |
| |
| | |
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| | |
| |
| |
| | |
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| | |
| |
| |
| | |
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| | |
| |
| |
| | |
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| | |
| |
| |
| | |
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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>
|
| | |
| |
| |
| |
| |
| |
| | |
function old new delta
less_main 2105 2062 -43
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| | |
| |
| |
| |
| |
| |
| |
| |
| | |
From: Weixie Cui <cuiweixie@gmail.com>
function old new delta
update_status 608 607 -1
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| | |
| |
| |
| |
| |
| |
| | |
function old new delta
option_to_env 694 711 +17
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| | |
| |
| |
| | |
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| | |
| |
| |
| |
| |
| |
| |
| |
| | |
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>
|
| | |
| |
| |
| | |
It broke single-character splitting
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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>
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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>
|