Fix bug introduced in busybox 1.37.0 that broke kernel builds.

Fixes commit e2287f99fe6f (od: for !DESKTOP, match output more closely
to GNU coreutils 9.1, implement -s)

Signed-off-by: Natanael Copa <nc...@alpinelinux.org>
---
 libbb/dump.c            | 6 ++++--
 testsuite/hexdump.tests | 6 ++++++
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/libbb/dump.c b/libbb/dump.c
index b406a2428..2ca9919da 100644
--- a/libbb/dump.c
+++ b/libbb/dump.c
@@ -198,9 +198,11 @@ static NOINLINE void rewrite(priv_dumper_t *dumper, FS *fs)
                                if (!e)
                                        goto DO_BAD_CONV_CHAR;
                                pr->flags = F_INT;
-                               if (e > int_convs + 1) /* not d or i? */
-                                       pr->flags = F_UINT;
                                byte_count_str = "\010\004\002\001";
+                               if (e > int_convs + 1) { /* not d or i? */
+                                       pr->flags = F_UINT;
+                                       byte_count_str++;
+                               }
                                goto DO_BYTE_COUNT;
                        } else
                        if (strchr(int_convs, *p1)) { /* %d etc */
diff --git a/testsuite/hexdump.tests b/testsuite/hexdump.tests
index be0379cfc..517ec508b 100755
--- a/testsuite/hexdump.tests
+++ b/testsuite/hexdump.tests
@@ -82,4 +82,10 @@ testing "hexdump -e /2 %d" \
 "\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f"\
 "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff"\
 
+testing "hexdump -n4 -e '\"%u\"'" \
+       "hexdump -n4 -e '\"%u\"'" \
+       "12345678" \
+       "" \
+       "\x4e\x61\xbc\x00AAAA"
+
 exit $FAILCOUNT
-- 
2.46.2

_______________________________________________
busybox mailing list
busybox@busybox.net
https://lists.busybox.net/mailman/listinfo/busybox

Reply via email to