aboutsummaryrefslogtreecommitdiff
path: root/libbb (follow)
Commit message (Collapse)AuthorAgeFilesLines
...
| * shell: fix race between signal handlers setting bb_got_signal and poll()Denys Vlasenko2025-07-023-6/+57
| | | | | | | | | | | | | | | | | | | | | | | | function old new delta __ppoll_time64 - 211 +211 check_got_signal_and_poll - 164 +164 read_key 607 601 -6 shell_builtin_read 1328 1318 -10 ------------------------------------------------------------------------------ (add/remove: 4/0 grow/shrink: 0/2 up/down: 375/-16) Total: 359 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * use pollfd[1] array for poll() argumentDenys Vlasenko2025-07-021-5/+6
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * libbb: Prevent clang from reading the G pointer before it is assignedBin Meng2025-07-011-1/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It was observed that getty crashes on RISC-V 64-bit target, with the busybox binary compiled by clang/LLVM 17 with -O2. Not only getty, but also some other applets like syslogd/vi are broken too. Commit 5156b245 ("Make const ptr assign as function call in clang") introduced XZALLOC_CONST_PTR() to defeat the compiler optimization, however it only fixed a small number of broken places when compiling busybox with clang/LLVM. A large number of places remain broken. This commit treats ASSIGN_CONST_PTR() the same way as XZALLOC_CONST_PTR(). Signed-off-by: Bin Meng <bmeng.cn@gmail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * hexdump: fix regression for uint16 on big endian systemsRadoslav Kolev2025-07-011-2/+8
| | | | | | | | | | | | | | | | | | Commit 34751d8bf introduced a bug in the handling of uint16 values on big endian systems not considered safe for unaligned access when falling back to memcpy. Signed-off-by: Radoslav Kolev <radoslav.kolev@suse.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * lineedit: fix left-over print to stdoutAhmad Fatoum2025-07-011-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | There's code printing to stderr both before and after the single call to puts inside put_cur_glyph_and_inc_cursor(). This is likely an oversight as we want everything to go through the same file descriptor, so switch it over to fputs. Fixes: fd47f056765a ("lineedit: print prompt and editing operations to stderr") Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * lineedit: fix printing lines during tab completionAhmad Fatoum2025-07-011-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | Indentation and escape characters are all output to stderr now, but the matches themself remained on stdout leading to garbled output on Tab completion. Print the results to stderr as well to fix this. Fixes: fd47f056765a ("lineedit: print prompt and editing operations to stderr") Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Call BCryptDestroyHash before freeing memory handleRFL8902025-07-301-0/+1
| |
* | stty: enable a minimal Windows implementationRon Yorston2025-07-251-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Implement a minimal stty applet for Windows. - Display and set terminal rows and columns - Enable/disable raw/cooked mode - Enable/disable echo mode - Implement 'stty sane' to reset raw/cooked/echo Adds 2120-2304 bytes. (GitHub issue #58)
* | win32: deduplicate die_if_error()Ron Yorston2025-07-111-14/+5
| | | | | | | | | | | | | | There were two copies of the static function die_if_error(). Replace these with a single external function. Saves 16 bytes.
* | patch tls.c to work with CNG implementationRFL8902025-07-111-1/+1
| |
* | Use Windows library for cryptographic checksumscng_backendRon Yorston2025-06-092-0/+96
| | | | | | | | | | | | | | | | | | | | | | | | | | Add a new feature to libbb, FEATURE_USE_CNG_API, which enables the use of the Cryptography API: Next Generation library to calculate checksums. It is disabled by default except in the mingw64u default config, as the API requires Windows 10+ to function. Usage of this API provides a size benefit and delegates hardware optimizations to the operating system cryptography library. Based on GitHub PR #498 by rfl890. Saves 4064 bytes in the mingw64u case.
* | win32: enhanced support for SIGPIPEFRP-5579-g5749feb35Ron Yorston2025-02-081-4/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit 68ddd4ec3c (win32: emulate SIGPIPE) allowed broken pipes to be detected so that processes could either return EPIPE or terminate. Later, commit 1b2ee3667 (win32: add fake HUP and QUIT signals) added support for two additional fake signals, thus allowing the 'kill' applet to refer to them by name and the shell to define (though not execute) traps for them. Add PIPE to the list of signals known to 'kill' and the shell, though still without support for calling the trap function. (GitHub issue #482)
* | make: support GNU/BSD suffixes and inference rulesRon Yorston2025-01-141-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The specification of inference rules in POSIX implies that only suffixes starting with a period and containing no other periods are to be considered. In contrast, both GNU and BSD make allow suffixes to contain an arbitrary number of periods, or none at all. Allow this as an extension. Adds 640-816 bytes. (pdpmake GitHub issue 70)
* | Merge branch 'busybox' into mergeRon Yorston2024-12-302-12/+11
|\|
| * cut: tweak --helpDenys Vlasenko2024-12-111-2/+2
| | | | | | | | | | | | | | | | | | | | | | function old new delta packed_usage 34901 34934 +33 cut_main 1353 1339 -14 .rodata 105724 105685 -39 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/2 up/down: 33/-53) Total: -20 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * hexdump: fix regression with -n4 -e '"%u"'Natanael Copa2024-12-091-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | Fix bug introduced in busybox 1.37.0 that broke kernel builds. Fixes commit e2287f99fe6f (od: for !DESKTOP, match output more closely to GNU coreutils 9.1, implement -s) function old new delta rewrite 967 976 +9 Signed-off-by: Natanael Copa <ncopa@alpinelinux.org> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * libbb: tidy argument checks in getopt32()Ron Yorston2024-12-091-8/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When getopt32() has complementary options it's possible to specify the minimum and maximum number of arguments allowed. Checking these values was inconsistent: - '?' correctly checked that it was followed by a digit but set the otherwise unused spec_flgs variable on error. - '=' failed to check that it was followed by a digit. function old new delta vgetopt32 1307 1319 +12 Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | id: code shrinkRon Yorston2024-10-091-0/+2
| | | | | | | | | | | | | | | | The bogus user/group ids we use on Windows are very limited. Make these limitations explicit in the 'id' applet. Saves 464 bytes.
* | Merge branch 'busybox' into mergeRon Yorston2024-10-082-26/+32
|\|
| * libbb: modify find_executable() to not temporarily write to PATHDenys Vlasenko2024-10-081-26/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | This allows to simplify "which" applet code function old new delta find_executable 93 111 +18 which_main 191 177 -14 builtin_source 316 294 -22 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/2 up/down: 18/-36) Total: -18 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | libbb: code shrink supplementary group testRon Yorston2024-10-081-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | Recent upstream changes to file permission tests added a function to check and cache values in the supplementary group list. The implementation of getgroups() in the Windows port adds no useful information beyond what can be obtained by checking the current effective gid, which all callers of the new function already do. The function can be replaced with a simple 'FALSE'. Saves 232-288 bytes.
* | Merge branch 'busybox' into mergeRon Yorston2024-10-082-0/+36
|\|
| * ash: cache more of uid/gid syscallsDenys Vlasenko2024-10-071-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Testcase: setuidgid 1:1 strace ash -c 'test -x TODO; test -x TODO; echo $?' should show that second "test -x" does not query ids again. function old new delta ash_main 1236 1256 +20 get_cached_euid - 19 +19 get_cached_egid - 19 +19 test_main 56 72 +16 test_exec 119 135 +16 is_in_supplementary_groups 52 57 +5 nexpr 718 702 -16 ------------------------------------------------------------------------------ (add/remove: 2/0 grow/shrink: 4/1 up/down: 95/-16) Total: 79 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * libbb: simplify parameter passing in is_in_supplementary_groups()Denys Vlasenko2024-10-071-5/+5
| | | | | | | | | | | | | | | | | | | | | | function old new delta is_in_supplementary_groups 54 52 -2 nexpr 721 718 -3 test_exec 125 119 -6 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/3 up/down: 0/-11) Total: -11 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * libbb: move is_in_supplementary_groups() from test to libbbDenys Vlasenko2024-10-071-0/+20
| | | | | | | | | | | | | | | | | | | | function old new delta is_in_supplementary_groups - 54 +54 nexpr 766 721 -45 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 0/1 up/down: 54/-45) Total: 9 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * libbb: fix sha1 on !x86 if CONFIG_SHA1_HWACCEL=yRudi Heitbaum2024-10-061-0/+2
| | | | | | | | | | | | | | | | | | | | | | fixes non i386 and x86 builds libbb/hash_md5_sha.c: In function 'sha1_end': libbb/hash_md5_sha.c:1316:35: error: 'sha1_process_block64_shaNI' undeclared 1316 | || ctx->process_block == sha1_process_block64_shaNI Signed-off-by: Rudi Heitbaum <rudi@heitbaum.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | win32: work around problem with stderr in MSVCRTRon Yorston2024-09-301-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Try to run a non-existent command with standard error closed: xyz 2>&- In recent versions of busybox-w32 this resulted in problems with moving through history (either using up/down keys or ctrl-r) and tab completion. In all cases the order of the prompt and the command were reversed. Bisection showed the problem was first seen in PRE-5396 which merged some commits from upstream, including fd47f0567 (lineedit: print prompt and editing operations to stderr). This (eventually) called to mind a previous problem with stderr in xargs which was fixed by commit f192e6539 (xargs: fix 'xargs -sNUM' tests). In both cases it seemed that mixing calls to bb_putchar_stderr() and fprintf(stderr, ...) was at fault. The former uses a file descriptor while the latter uses a stream. It was almost as if the stream was buffered. - The problem with xargs affected 32-bit and 64-bit builds with MSVCRT. - The problem with '2>&-' only affected 32-bit builds with MSVCRT. - Neither problem was present with UCRT builds. As a workaround change bb_putchar_stderr() to use the stderr stream in builds for MSVCRT. Saves 16 bytes in the 32-bit build. (GitHub issue #460)
* | Merge branch 'busybox' into mergeRon Yorston2024-09-282-40/+37
|\|
| * lineedit: use stdout for shell history builtinRon Yorston2024-09-271-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit fd47f0567 (lineedit: print prompt and editing operations to stderr) changed various print statements to output to stderr. The change in show_history() caused the shell history builtin to send its output to stderr. Revert that part of the commit. function old new delta show_history 47 42 -5 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-5) Total: -5 bytes Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * libbb: send usage messages to correct streamRon Yorston2024-09-271-13/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | POSIX generally requires normal output to go to stdout and diagnostic (i.e. error) output to go to stderr. When usage messages for BusyBox applets are specifically requested by the user (e.g. 'find --help') they should go to stdout; when they're emitted due to an error they should go to stderr. function old new delta bb_show_usage 148 146 -2 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-2) Total: -2 bytes Signed-off-by: Avi Halachmi <avihpit@yahoo.com> Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * libbb: use full_write1_str() to shrink busybox_main()Ron Yorston2024-09-271-13/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There are two calls to dup2() in busybox_main(). These were introduced to coerce full_write2_str() into writing to stdout. The relevant commits were: 21278dff7 (busybox: do not print help to fd 2, print it to fd 1) and 5a7c72015 (busybox --list option. +140 bytes. Rob wanted it.) Later, in commit 729ecb87b (bbconfig: make it independent from printf functions), the function full_write1_str() was added. Using this in busybox_main() allows us to drop the dup2() calls. function old new delta run_applet_and_exit 796 760 -36 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-36) Total: -36 bytes Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * lineedit: make save_history() FAST_FUNCDenys Vlasenko2024-09-271-1/+1
| | | | | | | | | | | | | | | | | | | | | | function old new delta save_history 267 266 -1 hush_exit 98 97 -1 exitshell 140 138 -2 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/3 up/down: 0/-4) Total: -4 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | win32: drop workaround for Wine console bufferRon Yorston2024-09-271-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit 1ade2225d2 (winansi: allow alternative screen buffer to be disabled) added a workaround for the broken alternative screen buffer in the Wine console. The problem has been fixed in Wine for well over a year: https://bugs.winehq.org/show_bug.cgi?id=54287 Remove the workaround. Saves 80-96 bytes.
* | ash: optimise running of scripts (2)Ron Yorston2024-09-041-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit 4b7b4a960 (ash: optimise running of scripts) avoided creation of a process when running a script. There's another case where we can do the same: if the script is being run from a FS_SHELLEXEC shell. - Check the necessary conditions for this to happen. - Allocate two extra slots in the argv array for FS_SHELLEXEC. - Set the index of the script file in the argv array. Without this the test 'pidof this' failed because the command name hadn't been correctly set. Adds 80-96 bytes.
* | win32: code shrinkRon Yorston2024-08-161-1/+1
| | | | | | | | | | Add the FAST_FUNC qualifier to several Windows-specific functions. This has no effect in 64-bit builds but saves 336 bytes for 32-bit.
* | lineedit: use stdout for shell history builtinRon Yorston2024-07-271-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | Commit fd47f0567 (lineedit: print prompt and editing operations to stderr) changed various print statements to output to stderr. The change in show_history() caused the shell history builtin to send its output to stderr. Revert that part of the commit. Saves 16 bytes. (GitHub issue #433)
* | Merge branch 'busybox' into mergeRon Yorston2024-07-131-6/+23
|\|
| * tls: fix CONFIG_FEATURE_TLS_SHA1=y + CONFIG_SHA1_HWACCEL=yDenys Vlasenko2024-07-121-6/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The check for result hash size was buggy for CONFIG_SHA1_HWACCEL=y. While at it, document CPUID use a bit better. function old new delta get_shaNI - 28 +28 sha1_end 66 79 +13 sha256_begin 83 60 -23 sha1_begin 111 88 -23 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 1/2 up/down: 41/-46) Total: -5 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | win32: code shrink system drive handlingRon Yorston2024-07-071-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A previous commit (e3bfe3695) revised the use of getsysdir() to obtain the system directory, and hence the system drive. See the commit message for the history to that point. Further improvements are possible: - Remove getsysdir() and push the calls to GetSystemDirectory() down into get_system_drive() and get_proc_addr(). - Check the return value of GetSystemDirectory(). It's unlikely to fail, but better safe than sorry. - Instead of making all callers of get_system_drive() check for a NULL return value always return a non-NULL pointer. If the drive can't be found an empty string is returned instead (which is what the callers were using anyway). - The function need_system_drive() was only used in one place (in httpd). Move the code there and remove the function. - Use concat_path_file() where possible. Saves 76-144 bytes.
* | Merge branch 'busybox' into mergeRon Yorston2024-06-234-28/+111
|\|
| * libbb: add bit counting function, use where appropriateDenys Vlasenko2024-05-312-0/+47
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Although "naive" counting function is not too slow and is smaller, using it on e.g. each of 1024 words of CPU mask feels wrong. function old new delta bb_popcnt_32 - 52 +52 get_prefix 323 321 -2 nproc_main 206 199 -7 d4_run_script 739 731 -8 ipcalc_main 533 507 -26 ------------------------------------------------------------------------------ (add/remove: 2/0 grow/shrink: 0/4 up/down: 52/-43) Total: 9 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * nproc: prepare for arbitrarily large CPU masksDenys Vlasenko2024-05-312-0/+30
| | | | | | | | | | | | | | | | | | | | | | function old new delta get_malloc_cpu_affinity - 76 +76 nproc_main 216 206 -10 process_pid_str 250 206 -44 ------------------------------------------------------------------------------ (add/remove: 2/0 grow/shrink: 0/2 up/down: 76/-54) Total: 22 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * lineedit: print prompt and editing operations to stderrDenys Vlasenko2024-04-131-28/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For shells, this is mandated by standards function old new delta input_backward 215 231 +16 read_line_input 3015 3028 +13 draw_custom 66 78 +12 put_cur_glyph_and_inc_cursor 149 159 +10 put_prompt_custom 47 56 +9 show_history 40 46 +6 input_tab 927 933 +6 input_delete 136 142 +6 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 8/0 up/down: 78/0) Total: 78 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | win32: code shrink BB_CRITICAL_ERROR_DIALOGSRon Yorston2024-06-231-1/+1
| | | | | | | | | | | | Rewrite the test for the value of BB_CRITICAL_ERROR_DIALOGS. Saves 16-48 bytes.
* | win32: add env var to control error dialogsRon Yorston2024-06-222-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If the environment variable BB_CRITICAL_ERROR_DIALOGS is set to 1 critical error dialogs are enabled. If unset or set to any other value they aren't. In either case the error messages introduced by commit 790e37727 (win32: revert 'don't set error mode') are issued. The shell exports BB_CRITICAL_ERROR_DIALOGS to the environment immediately on any change so the setting takes effect at once. Adds 104-160 bytes. (GitHub issue #423)
* | win32: revert 'don't set error mode'Ron Yorston2024-06-221-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit eb376b5d1 (win32: don't set error mode) removed a call to SetErrorMode(SEM_FAILCRITICALERRORS). But the documentation says: Best practice is that all applications call the process-wide SetErrorMode function with a parameter of SEM_FAILCRITICALERRORS at startup. This is to prevent error mode dialogs from hanging the application. Doing this prevents the system from displaying useful information, though. The application should attempt to tell the user what went wrong. Reinstate the call to SetErrorMode() and try to provide an error message, at least for the situation mentioned in issue #423 and other similar cases. Adds 360-368 bytes. (GitHub issue #423)
* | win32: don't set error modeRon Yorston2024-06-161-4/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit a8c63f25b3 (win32: improve filesystem detection and display) added a call to SetErrorMode(SEM_FAILCRITICALERRORS). This was on the strength of the documentation for GetVolumeInformation() which suggests that otherwise a message box will appear to prompt the user to put media in an empty floppy or CD drive. This would disrupt the expected behaviour of applets like 'df'. In practice it seems the call to SetErrorMode() is unnecessary. It also results in other errors going unreported. Remove the call to SetErrorMode(). Saves 8-20 bytes. (GitHub issue #423)
* | win32: allow for trailing separator in PATHRon Yorston2024-06-141-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In recent versions of Windows the PATH environment variable has a trailing semicolon. This is insignificant to Windows because it's ignored. busybox-w32 conforms to the POSIX interpretation of PATH which treats an empty path element as denoting the current directory. As result, on these versions of Windows executables may by default be run from the current directory, contrary to usual Unix practice. Attempt to detect and remove the trailing semicolon on applet start up. If the user insists, they can add a trailing semicolon to the shell variable PATH and it will be respected in the conventional manner. Adds 88-112 bytes. (GitHub issue #422)
* | libbb: make default history size configurableRon Yorston2024-04-282-2/+12
| | | | | | | | | | | | | | | | Allow the default history size (used if HISTFILESIZE isn't set) to be configured at build time. This may be less than or equal to the standard history size. (GitHub issue #411)
* | lineedit: reduce default history sizeRon Yorston2024-04-271-0/+4
| | | | | | | | | | | | | | | | | | Keep the maximum history size at 1023 but make the default 383. This gives a modest increase over the previous default of 255 while allowing users to increase or decrease the history size using the HISTFILESIZE environment variable. (GitHub issue #411)