| Commit message (Collapse) | Author | Age | Files | Lines |
... | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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>
|
| |
| |
| |
| |
| |
| |
| | |
function old new delta
get_file 185 201 +16
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>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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)
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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)
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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)
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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)
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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.
|
| |
| |
| |
| |
| | |
A misplaced #endif in ash and the wrong sense of a test in
parse_config.c broke the POSIX build.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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.
|
| |
| |
| |
| |
| |
| |
| |
| | |
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.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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.
|
| |
| |
| |
| |
| |
| |
| | |
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.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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.
|
| |
| |
| |
| |
| |
| |
| |
| | |
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)
|
| |
| |
| |
| |
| | |
This allows additional flexibility when another 'make' program is
present.
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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)
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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)
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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)
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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)
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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)
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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)
|
| | |
|
| |
| |
| |
| |
| | |
Upstream added the -o option to reopen stdin as /dev/tty. Since
/dev/tty isn't available in Microsoft Windows -o isn't applicable.
|
|\| |
|
| |
| |
| |
| | |
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| |
| |
| |
| | |
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
|
| |
| |
| |
| |
| |
| |
| | |
function old new delta
run_list 1032 1012 -20
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>
|