[openwrt/openwrt] busybox: fix regression for long long type dump support

LEDE Commits lede-commits at lists.infradead.org
Thu Dec 4 03:16:02 PST 2025


robimarko pushed a commit to openwrt/openwrt.git, branch main:
https://git.openwrt.org/9c6dbb0e3d6c165c4924dd4ab10b27778a8c520c

commit 9c6dbb0e3d6c165c4924dd4ab10b27778a8c520c
Author: Shiji Yang <yangshiji66 at outlook.com>
AuthorDate: Tue Dec 2 00:06:45 2025 +0800

    busybox: fix regression for long long type dump support
    
    Fix wrong output using '%d' format when byte count parameter is not
    given.
    
    Signed-off-by: Shiji Yang <yangshiji66 at outlook.com>
    Link: https://github.com/openwrt/openwrt/pull/21013
    Signed-off-by: Robert Marko <robimarko at gmail.com>
---
 package/utils/busybox/Makefile                     |  2 +-
 ...fix-dumping-of-signed-values-without-expl.patch | 68 ++++++++++++++++++++++
 2 files changed, 69 insertions(+), 1 deletion(-)

diff --git a/package/utils/busybox/Makefile b/package/utils/busybox/Makefile
index 63c1dceee3..e5b7c2c780 100644
--- a/package/utils/busybox/Makefile
+++ b/package/utils/busybox/Makefile
@@ -6,7 +6,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=busybox
 PKG_VERSION:=1.37.0
-PKG_RELEASE:=5
+PKG_RELEASE:=6
 PKG_FLAGS:=essential
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
diff --git a/package/utils/busybox/patches/100-libbb-dump-fix-dumping-of-signed-values-without-expl.patch b/package/utils/busybox/patches/100-libbb-dump-fix-dumping-of-signed-values-without-expl.patch
new file mode 100644
index 0000000000..665dc6042c
--- /dev/null
+++ b/package/utils/busybox/patches/100-libbb-dump-fix-dumping-of-signed-values-without-expl.patch
@@ -0,0 +1,68 @@
+From: Sven Wegener <sven.wegener at stealer.net>
+Subject: [PATCH] libbb/dump: fix dumping of signed values without explicit
+ size specifier
+
+Message-ID: <05d87e73-d0e0-d9ef-561a-8a9180888627 at stealer.net>
+
+Commit e2287f99fe6f21fd6435ad04340170ad4ba5f6b3 added support for the 64
+bit signed format %lld, accidentally changing the default size of the %d
+format to eight bytes and producing the following:
+
+root at openwrt:~# for i in $(seq 0 7); do hexdump -s $i -n 1 -e '"%d\n"' /dev/mtdblock0; done
+0
+0
+0
+0
+0
+0
+0
+0
+root at openwrt:~# for i in $(seq 0 7); do hexdump -s $i -n 1 -e '/4 "%d\n"' /dev/mtdblock0; done
+255
+0
+0
+16
+0
+0
+0
+0
+
+With -n 1 the input is zero-padded. On big-endian, when the input is copied
+into the 64 bit variable, the input byte ends up in the highest byte. As the %d
+format only interprets the lower 32 bits, the input byte is lost during
+printing.
+
+Depending on how the architecture passes 64 bit parameters, the same
+happens on little-endian as well. x86 (little-endian) works correctly,
+but MIPS experiences the same behavior on big-endian and little-endian.
+
+Fixes: e2287f99fe6f21fd6435ad04340170ad4ba5f6b3
+See: https://github.com/openwrt/openwrt/issues/18808
+Signed-off-by: Sven Wegener <sven.wegener at stealer.net>
+---
+ libbb/dump.c | 7 ++++---
+ 1 file changed, 4 insertions(+), 3 deletions(-)
+
+--- a/libbb/dump.c
++++ b/libbb/dump.c
+@@ -192,16 +192,17 @@ static NOINLINE void rewrite(priv_dumper
+ 				if (*p1 == 'l') { /* %lld etc */
+ 					++p2;
+ 					++p1;
+-				}
++					byte_count_str = "\010\004\002\001";
++				} else {
+  DO_INT_CONV:
++					byte_count_str = "\004\002\001";
++				}
+ 				e = strchr(int_convs, *p1); /* "diouxX"? */
+ 				if (!e)
+ 					goto DO_BAD_CONV_CHAR;
+ 				pr->flags = F_INT;
+-				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




More information about the lede-commits mailing list