aboutsummaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
...
| * hush: restore tty pgrp on SIGHUPDenys Vlasenko2023-01-301-5/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | Found one case where SIGHUP does need some handling. ash does not restore tty pgrp when killed by SIGHUP, and this means process which started ash needs to restore it, or it would get backgrounded when trying to use tty. function old new delta check_and_run_traps 214 229 +15 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * hush: remove special handling of SIGHUPDenys Vlasenko2023-01-301-18/+20
| | | | | | | | | | | | | | | | | | | | Kernel should do the right thing. (ash and dash do not have special SIGHUP handling.) function old new delta check_and_run_traps 278 214 -64 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * shell: fix SIGWINCH and SIGCHLD (in hush) interrupting line input, closes 15256Denys Vlasenko2023-01-263-10/+20
| | | | | | | | | | | | | | | | | | | | function old new delta record_pending_signo 32 63 +31 lineedit_read_key 231 224 -7 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/1 up/down: 31/-7) Total: 24 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * nmeter: increase maximum /proc file size (needed for large machines)Denys Vlasenko2023-01-241-3/+6
| | | | | | | | | | | | | | function old new delta get_file 185 201 +16 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ntpd: correct comment: 2^-20 is ~1 microsecond (confused with 10^-20)Denys Vlasenko2023-01-181-1/+1
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ntpd: fold d_to_tv() into its only callerDenys Vlasenko2023-01-181-8/+10
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ntpd: correct fixed->float conversions of fractionsDenys Vlasenko2023-01-171-4/+4
| | | | | | | | | | | | | | | | | | | | Need to divide by (1<<32), not by (1<<32)-1. Fraction of 0xffffffff is not 1 whole second. function old new delta .rodata 105264 105268 +4 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ntpd: make NTP client and server Y2036/2038-readyMiroslav Lichvar2023-01-171-3/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The 32-bit integer part of the NTP timestamp overflows in year 2036, which starts the second NTP era. Modify the timestamp conversion to shift values between 1900-1970 (in the first era) to the second era to enable the client to measure its offset correctly until year 2106 (assuming 64-bit time_t). Also update the conversion from double used when stepping the clock to work with 64-bit time_t after reaching the maximum 32-bit value in 2038 and the server conversion to work correctly in the next NTP era. function old new delta lfp_to_d 51 64 +13 step_time 326 332 +6 .rodata 105260 105264 +4 d_to_lfp 100 86 -14 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 3/1 up/down: 23/-14) Total: 9 bytes Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ed: don't use memcpy with overlapping memory regionsSören Tempel2023-01-051-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The memcpy invocations in the subCommand function, modified by this commit, previously used memcpy with overlapping memory regions. This is undefined behavior. On Alpine Linux, it causes BusyBox ed to crash since we compile BusyBox with -D_FORTIFY_SOURCE=2 and our fortify-headers implementation catches this source of undefined behavior [0]. The issue can only be triggered if the replacement string is the same size or shorter than the old string. Looking at the code, it seems to me that a memmove(3) is what was actually intended here, this commit modifies the code accordingly. [0]: https://gitlab.alpinelinux.org/alpine/aports/-/issues/13504 Signed-off-by: Sören Tempel <soeren+git@soeren-tempel.net> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | ash: improve CRLF handling in readRon Yorston2023-02-122-0/+40
| | | | | | | | | | | | | | | | | | | | | | Commit deae0c7bf3 (Skip carriage return in read builtin command) caused all CRs to be removed from input to the read builtin. Only remove CRs that are part of a CRLF pair. Adds 64-80 bytes. (GitHub issue #285)
* | ash: remove CRs from CRLF during field splittingRon Yorston2023-02-103-5/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | Commit e371e46fa0 (shell: add \r to IFS) added '\r' to the IFS variable so field splitting would remove carriage returns. Rather than change IFS, remove CRs preceding LFs in regions being scanned for field splitting before IFS is applied. This prevents free-standing CRs from being removed. Costs 112-120 bytes. (GitHub issue #285)
* | ash: change CRLF handlingRon Yorston2023-02-073-7/+55
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As noted in commit 2d848eba5 (ash: fix CRLF handling) all CRs are removed when scripts are read. Allow an alternative approach (configurable at build-time, enabled by default): - Do not strip CRs from input. - Treat CR as similar to space or tab in base syntax mode. - Adjust pgetc_eatbnl() to handle backslash-CRLF in the same way as backslash-LF. With these changes scripts containing CRLF line endings are more likely to work. Adds 48-56 bytes. (GitHub issue #285)
* | vi: introduce 'binary' option and '-b' flagRon Yorston2023-02-061-11/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | vim has the 'binary' option and corresponding '-b' command line flag. These allow files to be opened in binary mode, ignoring the 'fileformats' setting and treating all files as of type 'unix'. Add these to busybox-w32 vi so it's possible to edit files which have a mixture of different line endings. Costs 80-112 bytes. (GitHub issue #285)
* | vi: allow change of 'fileformat' optionRon Yorston2023-02-061-12/+23
| | | | | | | | | | | | | | | | | | For some reason the 'fileformat' option was made read-only when it was introduced in commit 420afde92e (vi: add fileformats option). I think I'd read some vim documentation that made it seem more complicated than it really is. Costs 48 bytes.
* | Fix POSIX buildRon Yorston2023-02-042-2/+2
| | | | | | | | | | A misplaced #endif in ash and the wrong sense of a test in parse_config.c broke the POSIX build.
* | make: strip leading whitespace in shell assignmentRon Yorston2023-02-011-11/+28
| | | | | | | | | | | | | | | | | | | | | | | | Assignment of shell output to a macro ('!=') was originally a non-POSIX extension. It later became a POSIX 202X feature. However, the implementation failed to include the additional POSIX requirement that leading whitespace is removed from the shell output. Neither GNU make nor bmake strip leading whitespace. Implement this behaviour as a non-POSIX extension.
* | ash: fix CRLF handlingRon Yorston2023-01-311-2/+7
| | | | | | | | | | | | | | | | Only remove CRs that are part of a CRLF pair in the output of command substitution. It would be nice to do the same in preadbuffer() but there's a small chance the CRLF might be split between buffers.
* | libbb: fix CRLF handlingRon Yorston2023-01-312-4/+14
| | | | | | | | | | | | | | | | | | | | Ensure a trailing CR is only removed if it precedes a LF. The two cases at issue are intended to read complete lines and remove the line terminator. In the normal case a trailing LF will be present so removing the CR unconditionally worked. However, if the last line of a file was missing its LF or if a NUL was detected (in the case of xmalloc_fgetline()) the CR might have been removed without justification.
* | ash,make: fix CRLF handlingRon Yorston2023-01-302-2/+9
| | | | | | | | | | | | | | Fix remove_cr() so it only removes CRs which are part of a CRLF pair, not every CR. Add a test case for the shell.
* | awk: CRLF handlingRon Yorston2023-01-302-19/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previous efforts at handling DOS-style line endings in awk have included commits ee7e00dc5 and 1a3717342. The use of remove_cr() is unwise: - It's overzealous, removing all CRs, not just those in CRLF pairs. - Even if that were fixed awk reads input in chunks. There's a remote chance a CRLF might appear at a chunk boundary and be missed. remove_cr() will be fixed separately. In awk treat all data input as being in text mode. Skipping CRs in skip_spaces() is also flawed. Instead read scripts in text mode. Add a couple of test cases. One of these (awk backslash+CRLF eaten with no trace) fails without this patch.
* | diff: improve --binary implementationRon Yorston2023-01-291-13/+7
| | | | | | | | | | | | | | | | | | | | | | Commit 82f0d19b1 (diff: implement --binary flag) was both over- complicated and incorrect. If stdin was seekable it was left in binary mode even if the --binary flag wasn't supplied. Always open files in binary mode. Only switch to text mode at the last moment, if necessary. Saves 48 bytes.
* | win32: provide a default value for HOMERon Yorston2023-01-292-9/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The busybox-w32 shell initialises HOME when it starts. However, if applets are run outside the environment provided by the shell they may find HOME is unset. This caused a problem for 'vi' as it was unable to locate its .exrc. If HOME isn't available in the environment make getenv(3) provide a sensible default value. The shell must use the *real* getenv(3) when determining if HOME is already set. Also, unrelated to the above, the shell shouldn't treat failure of getpwuid(3) as a fatal error. Costs 72-80 bytes.
* | diff: implement --binary flagRon Yorston2023-01-271-0/+25
| | | | | | | | | | | | | | | | | | | | | | On Windows GNU diff uses text mode for input and output. It also has the '--binary' flag to use binary mode instead. On Unix binary mode is the default and the flag does nothing. Alter diff to use text mode by default for input (though not output, let's not go overboard). Add the '--binary' flag to override this. Costs 96-160 bytes.
* | win32: another stat(2) + access time fixRon Yorston2023-01-261-1/+1
| | | | | | | | | | | | | | | | Use FILE_SHARE_READ when opening a file to check if it's an executable. Without that other processes running in parallel might be unable to access the file. (GitHub issue #284)
* | make: enable pdpmake alias in default configurationRon Yorston2023-01-242-2/+2
| | | | | | | | | | This allows additional flexibility when another 'make' program is present.
* | make: allow building as pdpmake onlyRon Yorston2023-01-242-0/+2
| | | | | | | | | | | | | | | | | | Commit f261d2d27 (make: make + sh configuration) added 'pdpmake' as an alias for 'make'. It should have been possible to include 'pdpmake' in a build without also including 'make'. Adjust the build configuration so this works as intended.
* | win32: only count subdirectories if necessaryRon Yorston2023-01-234-3/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit 7fb95a2a5 (win32: try to get link count for directories) allowed stat(2) to report accurate values of st_nlink for directories. There are only a couple of places in busybox-w32 where these values are required. Disable counting of subdirectories by default and only enable it when necessary. Microsoft kindly provide directories to test edge cases like this: C:/Windows/WinSxS (contains many subdirectories) C:/Windows/WinSxS/Manifests (contains many files) Adds 84-112 bytes.
* | win32: limit setting of errno when lazy loading failsRon Yorston2023-01-221-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | The function get_proc_addr() facilitates dynamic loading of functions from DLLs. In the event of failure it set errno to ENOSYS. This is sometimes useful, such as in the implementations of link(2), symlink(2) and realpath(3). However, many other uses of lazy loading can recover from failure or simply don't care. In these cases setting errno is unnecessary and may be counterproductive. (GitHub issue #283)
* | win32: reset errno in read_key()Ron Yorston2023-01-221-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | The WIN32 implementation of read_key() didn't reset errno to zero, unlike the upstream version. This could result in invalid non-zero errno values after calls to lineedit_read_key(). For example, after an attempt to run a non-existent command in the shell errno is set to ENOENT. If the shell had vi line edit mode enabled any command that reads an additional character (e.g. 'c' or 'd') would see the non-zero errno and report EOF. (GitHub issue #283)
* | win32: more minor improvements to stat(2)Ron Yorston2023-01-181-29/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The previous commit incorrectly stated that preventing the access time of a file from being updated only required it to be opened with GENERIC_READ access. In fact, even though we don't want to update the access time, SetFileTime() also requires the file to have been opened with FILE_WRITE_ATTRIBUTES access. There's no need to explicitly avoid device files when checking for execute mode: since device files are now 'character special' they are excluded by the test that the file is 'regular'. Device files should be excluded when trying to obtain extra file data using GetFileInformationByHandle(). It shouldn't be possible for CreateFile() to open then, so there's no point in trying.
* | win32: minor improvements to stat(2)Ron Yorston2023-01-171-9/+9
| | | | | | | | | | | | | | | | | | | | | | Commit b11352dcb (win32: prevent stat(2) from updating access times) requested GENERIC_ALL access when opening files. It appears that GENERIC_READ is sufficient and also faster. The code to find the actual size of compressed or sparse files only needs to be invoked for regular files. Avoiding unnecessary calls to GetCompressedFileSize() makes stat(2) slightly faster and gives a more accurate number of blocks for symbolic links.
* | win32: use ACL check to clarify write permissionRon Yorston2023-01-161-27/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | On Microsoft Windows a user's home directory doesn't belong to them: it actually belongs to the 'system' user. stat(2) was only using ownership to determine write permissions, so it seemed that the user was unable to write to their own home directory. Use a call to AccessCheck() to determine if files can be accessed due to an entry in their ACL. User home directories and a few other files (e.g. C:/Users/Public) now have the correct write permission. This feature is enabled by FEATURE_EXTRA_FILE_DATA. Costs 220-256 bytes. (GitHub issue #280)
* | win32: fix permissions of read-only directoryRon Yorston2023-01-111-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | Commit 15fcbd19c8 (win32: special case for devices files in stat(2)) caused write permissions on directories to respect the read-only attribute. This is incorrect: the read-only attribute doesn't apply to directories in the same way as to normal files. Give directories write permission unconditionally, as before, though respecting umask. (GitHub issue #280)
* | win32: improve seeding of PRNGsRon Yorston2023-01-112-60/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | busybox-w32 provides two PRNG implementations which are used in the emulation of /dev/urandom. The ad hoc method of seeding them has been replaced by calls to RtlGenRandom. The documentation for RtlGenRandom indicates it has been deprecated in favour of CryptGenRandom. The documentation for the latter indicates it has been deprecated in favour of the 'Cryptography Next Generation APIs'. Nonetheless, RtlGenRandom remains available in every version of Windows since XP. In the unlikely event that RtlGenRandom fails simply use the current time as the seed. Saves 192 bytes in the default configuration.
* | awk: further improvements to randomnessRon Yorston2023-01-111-0/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | POSIX requires that the awk srand() function uses the time of day to seed the PRNG. The obvious implementation used in BusyBox does exactly that, passing time(NULL) to srand(3). When processes are started within a few seconds of one another their seeds are very similar. Given the realtively poor quality of rand(3) in some C runtimes this results in random number sequences that are somewhat correlated. Improve matters by using an integer hash on the seed, as recommended here: https://nullprogram.com/blog/2019/04/30/#the-wrong-places Costs 48 bytes. (GitHub issue #279)
* | awk: make random values more randomRon Yorston2023-01-061-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | When srand(3) is called to seed the random number generator with the current time the first value returned by rand(3) changes slowly with time. This is a property of the implementation in the C runtime. Change the order in which values from rand(3) are consumed to generate the value returned by the awk rand() function. This puts the value returned by the first call to rand(3) in the least significant bits, not the most significant. (GitHub issue #279)
* | Annual update of copyright messageRon Yorston2023-01-051-1/+1
| |
* | xargs: omit support for -oRon Yorston2023-01-051-3/+14
| | | | | | | | | | Upstream added the -o option to reopen stdin as /dev/tty. Since /dev/tty isn't available in Microsoft Windows -o isn't applicable.
* | Merge branch 'busybox' into mergeRon Yorston2023-01-0527-182/+397
|\|
| * Start 1.37.0 development cycleDenys Vlasenko2023-01-031-2/+2
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * Bump version to 1.36.01_36_0Denys Vlasenko2023-01-031-1/+1
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * hush: code shrinkDenys Vlasenko2023-01-031-4/+9
| | | | | | | | | | | | | | function old new delta run_list 1032 1012 -20 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * ash: trivial code shrinkDenys Vlasenko2023-01-031-1/+1
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * xxd: use bb_simple_perror_msg... where appropriateDenys Vlasenko2023-01-031-2/+2
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * shell: fix compile failures in some configsDenys Vlasenko2023-01-034-15/+31
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * Makefile.flags: add resolv to LDLIBS for linux compilers too (not only gnu ones)Denys Vlasenko2023-01-021-0/+3
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * sed: fix double-free in FEATURE_CLEAN_UP=y configsDenys Vlasenko2023-01-021-4/+13
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * mv: fix error in !VERBOSE configsDenys Vlasenko2023-01-021-2/+2
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * libbb/loop: fix compile failure (name collision)Denys Vlasenko2023-01-021-2/+2
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * testsuite/sha1sum.tests: fix false positive failureDenys Vlasenko2023-01-021-0/+2
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>