1
0
mirror of git://git.sv.gnu.org/coreutils.git synced 2026-04-21 11:16:16 +02:00

dd: fix parsing of numbers with more than two multipliers

* src/dd.c (parse_integer): Use recursion to support more than two
multipliers.  Also protect suffix[-1] access to ensure we don't
inspect before the passed string.
* tests/dd/bytes.sh: Add test cases.
* doc/coreutils.texi (dd invocation): Note the support for specifying
many multipliers in a number.
* NEWS: Mention the bug fix.
Fixes https://bugs.debian.org/1037275
This commit is contained in:
Pádraig Brady
2023-06-10 14:18:00 +01:00
parent b841f111de
commit e8e81fc44b
4 changed files with 21 additions and 5 deletions

View File

@@ -60,4 +60,16 @@ for operands in "oseek=8B" "seek=8 oflag=seek_bytes"; do
compare expected2 out2 || fail=1
done
# Check recursive integer parsing
for oseek in '1x2x4 oflag=seek_bytes' '1Bx2x4' '1Bx8' '2Bx4B' '2x4B'; do
# seek bytes
echo abcdefghijklm |
dd oseek=$oseek bs=5 > out 2> /dev/null || fail=1
compare expected out || fail=1
done
# Negative checks for integer parsing
for count in B B1 Bx1 KBB BB KBb KBx x1 1x 1xx1; do
returns_ 1 dd count=$count </dev/null >/dev/null || fail=1
done
Exit $fail