aboutsummaryrefslogtreecommitdiff
path: root/runit (unfollow)
Commit message (Collapse)AuthorFilesLines
2024-07-12make: allow pragmas to apply recursivelyRon Yorston1-14/+55
Pragmas set when pdpmake is run are exported to the environment variable PDPMAKE_PRAGMAS as a space-separated list of pragma names. This environment variable is read when pdpmake starts and any pragmas it contains are applied. Thus pragmas are passed to recursive invocations of pdpmake. PDPMAKE_PRAGMAS can also be set by the user. Adds 240-288 bytes.
2024-07-12tls: P256: improve x86_64 multiplication asm codeDenys Vlasenko1-22/+36
gcc is being rather silly. Usues suboptimal registers, and does not realize that i and j are never negative, thus usese even _more_ registers for temporaries to sign-extend i/j to 64-bit offsets. function old new delta sp_256_mont_mul_8 155 132 -23 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2024-07-11tls: P256: fix obscure x86_64 asm misbehavior, closes 15679Denys Vlasenko1-10/+29
gcc does not necessarily clear upper bits in 64-bit regs if you ask it to load a 32-bit constant. Cast it to unsigned long. Better yet, hand-write loading of the constant with a smaller instruction. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2024-07-11md5/shaXsum: accept uppercase hex stringsRon Yorston1-1/+1
The coreutils versions of md5sum and the like accept uppercase hex strings from checksum files specified with the '-c' option. Use a case-insensitive comparison so BusyBox does the same. Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2024-07-11vi: Ensure that the edit buffer ends in a newlinePetja Patjas1-3/+4
Currently vi assumes that the edit buffer ends in a newline. This may not be the case. For example: $ printf test > test $ vi test <press 'o'> We fix this by inserting a newline to the end during initialization. Signed-off-by: Petja Patjas <pp01415943@gmail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2024-07-10ash: remove defunct control character to save a few bytesRon Yorston1-12/+12
Commit 549deab5a (ash: move parse-time quote flag detection to run-time) did away with the need to distinguish between backquotes inside and outside quotes. This left a gap among the control characters used in argument strings. Removing this gap saves a few bytes. function old new delta .rodata 167346 167338 -8 cmdputs 399 388 -11 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-19) Total: -19 bytes Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2024-07-10Makefile.flags: suppress clang warnings when cross-compilingRon Yorston1-3/+3
Extend the changes introduced by commit b4ef2e3467 (Makefile.flags: suppress some clang-9 warnings) so they also cover the case where clang is used as a cross-compiler. Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2024-07-10ash: fix parsing of alias expansion + bash featuresRon Yorston1-6/+6
An alias expansion immediately followed by '<' and a newline is parsed incorrectly: ~ $ alias x='echo yo' ~ $ x< yo ~ $ sh: syntax error: unexpected newline The echo is executed and an error is printed on the next command submission. In dash the echo isn't executed and the error is reported immediately: $ alias x='echo yo' $ x< dash: 3: Syntax error: newline unexpected $ The difference between BusyBox and dash is that BusyBox supports bash-style process substitution and output redirection. These require checking for '<(', '>(' and '&>' in readtoken1(). In the case above, when the end of the alias is found, the '<' and the following newline are both read to check for '<('. Since there's no match both characters are pushed back. The next input is obtained by reading the expansion of the alias. Once this string is exhausted the next call to __pgetc() calls preadbuffer() which pops the string, reverts to the previous input and recursively calls __pgetc(). This request is satisified from the pungetc buffer. But the first __pgetc() doesn't know this: it sees the character has come from preadbuffer() so it (incorrectly) updates the pungetc buffer. Resolve the issue by moving the code to pop the string and fetch the next character up from preadbuffer() into __pgetc(). function old new delta pgetc 28 589 +561 __pgetc 607 - -607 ------------------------------------------------------------------------------ (add/remove: 0/1 grow/shrink: 1/0 up/down: 561/-607) Total: -46 bytes Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2024-07-10awk: mktime() with no arguments is not allowedDenys Vlasenko1-2/+1
It was SEGVing. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2024-07-10awk: improve comments and constants, no code changesDenys Vlasenko1-20/+27
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2024-07-09qwk: code shrinkDenys Vlasenko1-19/+19
function old new delta mk_splitter 100 96 -4 as_regex 103 99 -4 parse_expr 991 986 -5 awk_split 544 538 -6 awk_getline 559 552 -7 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/5 up/down: 0/-26) Total: -26 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2024-07-09awk: restore assignment precedence to be lower than ternary ?:Denys Vlasenko2-22/+74
Something is fishy with constrcts like "3==v=3" in gawk, they should not work, but do. Ignore those for now. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2024-07-09awk: do not infinitely recurse getvar_s() if CONVFMT is set to a numeric valueDenys Vlasenko1-6/+14
function old new delta fmt_num 247 257 +10 evaluate 3385 3379 -6 getvar_s 111 102 -9 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/2 up/down: 10/-15) Total: -5 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2024-07-09awk: fix use after free (CVE-2023-42363)Natanael Copa1-8/+13
function old new delta evaluate 3377 3385 +8 Fixes https://bugs.busybox.net/show_bug.cgi?id=15865 Signed-off-by: Natanael Copa <ncopa@alpinelinux.org> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2024-07-08chown: stop accepting deprecated USER.GROUP syntax, only : separator is allowedDenys Vlasenko1-5/+1
function old new delta parse_chown_usergroup_or_die 115 94 -21 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2024-07-08ash: restore value of imported variable on unexportRon Yorston1-0/+9
Shell variables imported from the environment are marked with a special flag and backslashes in their values are (by default) replaced with forward slashes. Sometimes this may not be what we want. Modify the 'export' shell built-in so unexporting a variable of this type restores its original value from the environment and removes its special flag. It can then be re-exported. Adds 32 bytes. (GitHub issue #428)
2024-07-08ash: read profile script relative to binaryRon Yorston4-3/+15
As well as trying to read '/etc/profile' also look for the script 'etc/profile' relative to the location of the running binary. Adds 64-96 bytes.
2024-07-08wget: ignore header casingSertonix1-1/+1
HTTP headers are case insensitive and therefore the check if a default header has been overwritten needs to be case insensitive. Without this patch `--header 'user-agent: test'` results in `User-Agent: Wget` and `user-agent: test` being send. function old new delta ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/0 up/down: 0/0) Total: 0 bytes text data bss dec hex filename 1040876 16443 1840 1059159 102957 busybox_old 1040876 16443 1840 1059159 102957 busybox_unstripped Signed-off-by: Sertonix <sertonix@posteo.net> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2024-07-07win32: code shrink system drive handling (2)Ron Yorston1-1/+1
Now that get_system_drive() no longer returns a NULL pointer on error chdir_system_drive() needs to check for an empty string instead.
2024-07-07win32: code shrink system drive handlingRon Yorston5-35/+22
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.
2024-07-07ash: special hack for libtoolRon Yorston1-0/+10
Libtool assumes the host environment is MSYS2 and will be confused by Windows-style command switches. The "/c" in "cmd /c" looks like a path, which MSYS2 incorrectly decodes to "c:/". Anticipating this, libtool encodes these calls as "cmd //c" which does not work outside MSYS2. A busybox-w32 patch makes it behave like MSYS2 in just this one case. Adds 88-96 bytes. (GitHub issue #297 and https://github.com/skeeto/w64devkit/issues/50)
2024-07-02win32: properly restore BB_ env varsRon Yorston1-1/+11
Some BB_ shell variables get special treatment: they're updated in the environment immediately on any change. One case was missed: if such a variable was unset or not exported and was overridden by a local variable it wasn't unset in the environment when the local variable went out of scope. Add the code required to do this. Adds 48-64 bytes. (GitHub issue #423)
2024-06-28win32: don't allow BB_TERMINAL_MODE=6Ron Yorston1-1/+1
The BB_TERMINAL_MODE variable is only documented to work for values between 0 and 5. Due to an oversight it also accepted the value 6. Like other unsupported values 6 is now replaced with the default value configured at build time.
2024-06-25win32: add definition for old mingw-w64FRP-5398-g89ae34445Ron Yorston1-0/+4
2024-06-24win32: code shrink exit_code_to_wait_status_cmd()Ron Yorston1-4/+4
Saves 16 bytes.
2024-06-23win32: code shrink BB_CRITICAL_ERROR_DIALOGSRon Yorston2-2/+3
Rewrite the test for the value of BB_CRITICAL_ERROR_DIALOGS. Saves 16-48 bytes.
2024-06-22win32: only access mode argument of open(2) if requiredRon Yorston1-3/+5
The wrapper function 'mingw_open()' should only read the optional third argument if the 'O_CREAT' flag bit is set. Adds 16 bytes. (GitHub issue #425)
2024-06-22win32: add env var to control error dialogsRon Yorston6-2/+12
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)
2024-06-22win32: revert 'don't set error mode'Ron Yorston2-29/+68
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)
2024-06-19ash: allow HISTFILE=/dev/null to work as intendedRon Yorston1-3/+8
It was noted that setting HISTFILE=/dev/null in upstream BusyBox prevented shell history from being saved to a history file. This failed in busybox-w32 with an error from lseek(2). The lseek(2) wrapper was rather conservative in the file types it accepted. Allowing FILE_TYPE_CHAR makes it possible to seek on /dev/null, thus avoiding the issue with HISTFILE. In addition, the wrapper for open(2) now converts the Unix-style mode argument to Windows-style. (GitHub issue #425)
2024-06-19win32: code shrink APE detection; avoid UBRon Yorston1-3/+7
Detecting Actually Portable Executable binaries used a longer signature than seems necessary. Six characters should be enough for anyone. When right shifting a byte by 24 bits, cast it to unsigned to avoid undefined behaviour. Saves 24-32 bytes. (GitHub issue #424)
2024-06-16make: update default rulesRon Yorston1-14/+49
The default rules were changed in the 2024 standard: - Fortran is no longer supported - The CC macro is set to 'c17' instead of 'c99' In addition to these changes, CC is set to 'cc' as a non-POSIX extension: on my system, at least, there isn't a 'c17' compiler. Adds 208-224 bytes.
2024-06-16win32: detect Actually Portable Executable binariesRon Yorston1-15/+23
Check for the signature of Actually Portable Executable binaries and treat them as executable. Adds 40-64 bytes. (GitHub issue #424)
2024-06-16win32: don't set error modeRon Yorston1-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)
2024-06-14make: update for POSIX 2024Ron Yorston6-27/+31
Now that POSIX.1-2024 has been released we can replace all references to the 202X draft standard with 2024. Make this change throughout the code and testsuite. The pragma 'posix_2024' has been added. 'posix_202x' remains as an alias for the same. The 2024 standard is enforced by default in POSIX mode.
2024-06-14win32: allow for trailing separator in PATHRon Yorston4-38/+47
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)
2024-06-10make: limit changes to pragmasRon Yorston1-5/+4
The special target .PRAGMA could be used to set or reset pragmas. Doing anything other than setting pragmas very early in execution is likely to be problematic. Limit the abilities of .PRAGMA: - Specifying .PRAGMA with no prerequisites now does nothing: pragmas are not reset. - The posix_2017 and posix_202x pragmas can only be used to change the enforced POSIX level from the default. Any further attempt to change POSIX level results in a warning. Adds 16-32 bytes.
2024-06-08make: allow := macro assignment on command lineRon Yorston1-14/+22
Only the forms of macro assignment required by POSIX were allowed on the command line. Add support for the non-POSIX := form too. Adds 16-24 bytes.
2024-06-05make: more changes for c:/path targetRon Yorston1-4/+5
The previous commit failed to change an instance of find_char() to find_colon(). It isn't necessary to use find_char() to replace find_colon() in the non-Windows case: strchr(3) is sufficient. Adds 16-48 bytes.
2024-06-05make: restore check for c:/path targetRon Yorston1-1/+23
Commit f9d10b2b6 (make: fix detection of target rules (take 2)) failed to include the function find_colon() which is used to skip targets of the form c:/path when checking for a target rule. Restore the function so Windows paths can be used as targets. Adds 48 bytes.
2024-06-04make: explicitly verify order of argumentsRon Yorston1-7/+16
POSIX requires macro assignments to precede targets on the command line. This requirement has been relaxed as a non-POSIX extension. Verify the constraint has been applied in POSIX mode. This ensures that the command: make --posix target A=1 fails before it tries to update the target. It also catches the case where POSIX mode had not been set with the --posix option or PDPMAKE_POSIXLY_CORRECT environment but was then set by the .POSIX special target in the makefile. In this case the command line was scanned for macro assignments without enforcing POSIX mode while targets were processed with POSIX mode enabled. Adds 96 bytes.
2024-06-03make: only reset getopt(3) if necessaryRon Yorston1-2/+2
Only invoke GETOPT_RESET() if getopt(3) has actually been called.
2024-06-02make: ensure sufficient space in line bufferRon Yorston1-7/+8
When using fgets(3) to read a line into a buffer it's necessary to ensure at least two characters are available in the buffer. Otherwise the read fails. (At least, it did when pdpmake was built using MSYS2 on Windows.) Adds 16 bytes to the 32-bit build. (GitHub pdpmake issue 44)
2024-06-02make: report POSIX 202X issue with includeRon Yorston1-6/+12
Synchronising with upstream pdpmake showed that a test was missing from the BusyBox port. POSIX 202X doesn't specify what should happen if an include statement has no arguments. When the POSIX 202X standard is being enforced this is reported as an error. Adds 32 bytes.
2024-06-02make: restore warning about invalid macro nameRon Yorston1-7/+9
Commit 90c5352a9 (make: change how macros are read from the environment) was intended to ignore environment variables with invalid names. It had the unintended consequence of also ignoring macros with invalid names defined in makefiles. This was because such macros can have the same level (3) as those imported from the environment. Rather than use the level to detect importing from the environment add a flag to indicate this circumstance.
2024-06-01make: move test for complex chain of macro assignmentsRon Yorston1-14/+14
The test 'Complex chain of macro assignments' relies on recursive macro expansion. This is a POSIX 202X feature, so the test should be moved to the appropriate section of the test script.
2024-06-01typo fixDenys Vlasenko2-2/+2
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2024-05-31libbb: fix 64-bit bb_popcnt_longDenys Vlasenko1-1/+1
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2024-05-31libbb: add bit counting function, use where appropriateDenys Vlasenko8-52/+66
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>
2024-05-31nproc: prepare for arbitrarily large CPU masksDenys Vlasenko5-27/+38
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>