Bug 13881

Summary: xxd -p -r fails with input longer than 30 bytes
Product: Busybox Reporter: Trammell Hudson <hudson>
Component: OtherAssignee: unassigned
Status: RESOLVED FIXED    
Severity: normal CC: busybox-cvs
Priority: P5    
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: Linux   
Host: Target:
Build:

Description Trammell Hudson 2021-06-29 14:50:08 UTC
version: 21fbee2e87ddf7b47bb501b6529b63ac2b3af0bd (git checkout 2021-06-29)

xxd -p -r discards input longer than 30 bytes when the characters are all on one line:

% echo "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f" \
| ./busybox xxd -p -r | xxd -g1
00000000: 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f  ................
00000010: 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d        ..............


% echo "000102030405060708090a0b0c0d0e0f 101112131415161718191a1b1c1d1e1f" \
| ./busybox xxd -p -r | xxd -g1
00000000: 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f  ................
00000010: 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d        ..............

Splitting the values onto separate lines works:

% echo "000102030405060708090a0b0c0d0e0f
101112131415161718191a1b1c1d1e1f" \
| ./busybox xxd -p -r | xxd -g1
00000000: 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f  ................
00000010: 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f  ................

Using the system xxd produces the expected result regardless of whitespace:

% echo "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f" \
| /usr/bin/xxd -p -r | xxd -g1
00000000: 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f  ................
00000010: 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f  ................
Comment 1 Denys Vlasenko 2021-10-08 21:04:26 UTC
Fixed in git, thank you