If a line specifies a binary checksum whose path contains two adjacent
spaces, when checking digests with -c the two spaces will be used as the
separator between the digest and the pathname instead of " *", as shown:
$ echo foo > "/tmp/two spaces"
$ md5sum -b "/tmp/two spaces" # This is GNU md5sum
d3b07384d113edec49eaa6238ad5ff00 */tmp/two spaces
$ md5sum -b "/tmp/two spaces" | ./busybox md5sum -c
md5sum: can't open 'spaces': No such file or directory
spaces: FAILED
md5sum: WARNING: 1 of 1 computed checksums did NOT match
function old new delta
md5_sha1_sum_main 503 496 -7
Signed-off-by: Emanuele Giacomelli <emanuele.giacomelli@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
The MBR partition type 0xF8 is used by the Arm EBBR specification[1] for
protective partitions over fixed-location firmware images.
[1]: https://github.com/ARM-software/ebbr
Signed-off-by: Vincent Stehlé <vincent.stehle@arm.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Apart from the -p option, POSIX also mandates an -s option which
suppresses the output of byte counts for the e, E, r, and w command.
From these commands, Busybox ed presently only implements the r and w
commands. This commit ensures that these two command do not output any
bytes counts when the -s option is passed. The shell escape command,
also effected by the -s option, is not implemented by Busybox at the
moment.
function old new delta
packed_usage 34096 34115 +19
doCommands 1887 1900 +13
readLines 388 397 +9
.rodata 104196 104200 +4
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 4/0 up/down: 45/0) Total: 45 bytes
Signed-off-by: Sören Tempel <soeren+git@soeren-tempel.net>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
It is perfectly valid to start a regex with ^ and have other patterns
with \| that can match more than once, e.g. the following example
should print ca, as illustrated with gnu sed:
$ echo 'abca' | sed -e 's/^a\|b//g'
ca
busybox before patch:
$ echo 'abca' | busybox sed -e 's/^a\|b//g'
bca
busybox after patch:
$ echo 'abca' | ./busybox sed -e 's/^a\|b//g'
ca
regcomp handles ^ perfectly well as illustrated with the second 'a' that
did not match in the example, we ca leave the non-repeating to it if
appropriate.
The check had been added before using regcomp and was required at the
time (f36635cec6) but no longer makes sense now.
(tested with glibc and musl libc)
function old new delta
add_cmd 1189 1176 -13
Signed-off-by: Dominique Martinet <asmadeus@codewreck.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
POSIX.1-2008 mandates the following regarding the read command:
If the read is successful, and -s was not specified, the number
of bytes read shall be written to standard output in the
following format:
"%d\n", <number of bytes read>
This commit aligns the output of busybox ed with POSIX.1-2008 by
removing the file name from the output for the read command.
This slipped through in 4836a0708fd0aaeb82871a3762b40fcf4b61e812.
function old new delta
.rodata 104203 104196 -7
readLines 409 388 -21
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-28) Total: -28 bytes
Signed-off-by: Sören Tempel <soeren+git@soeren-tempel.net>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
POSIX.1-2008 mandates the following regarding the file command-line
argument:
If the file argument is given, ed shall simulate an e command
on the file named by the pathname […]
The specification for the e command mandates the following behaviour
regarding the current line number in POSIX.1-2008:
The current line number shall be set to the address of the last
line of the buffer.
However, without this commit, busybox ed will set the current line
number to 1 if a file is given on the command-line and this file is not
empty (lastNum != 0). This is incorrect and fixed in this commit by not
modifying the current line number in ed_main(). As such, the current
line number will be zero for empty files and otherwise be set to the
address of the last line of the buffer.
function old new delta
ed_main 144 128 -16
Signed-off-by: Sören Tempel <soeren+git@soeren-tempel.net>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
The POSIX.1-2008 specification of ed(1) mandates two command-line
options: -p (for specifying a prompt string) and -s (to suppress writing
of byte counts). This commit adds support for the former. Furthermore,
it also changes the default prompt string to an empty string (instead
of ": ") since this is also mandated by POSIX:
-p string Use string as the prompt string when in command mode.
By default, there shall be no prompt string.
function old new delta
ed_main 112 144 +32
packed_usage 34074 34097 +23
doCommands 1889 1887 -2
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/1 up/down: 55/-2) Total: 53 bytes
Signed-off-by: Sören Tempel <soeren+git@soeren-tempel.net>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Add support to for "-n" to cmp in order to compare at most n bytes.
function old new delta
cmp_main 552 589 +37
.rodata 104198 104203 +5
packed_usage 34102 34074 -28
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/1 up/down: 42/-28) Total: 14 bytes
Signed-off-by: Walter Lozano <walter.lozano@collabora.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
The '%' character in a format specification may be followed by
one or more flags from the list "+- #0". BusyBox printf didn't
support the '0' flag or allow multiple flags to be provided.
As a result the formats '%0*d' and '%0 d' were considered to be
invalid.
The lack of support for '0' was pointed out by Andrew Snyder on the
musl mailing list:
https://www.openwall.com/lists/musl/2021/12/14/2
function old new delta
printf_main 860 891 +31
.rodata 99281 99282 +1
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 32/0) Total: 32 bytes
Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>