[git commit] hexdump: fix dup block comparison

Denys Vlasenko vda.linux at googlemail.com
Tue Oct 20 17:29:32 UTC 2020


commit: https://git.busybox.net/busybox/commit/?id=079487b48724d936b31a6696ae0f929b0251eaa3
branch: https://git.busybox.net/busybox/commit/?id=refs/heads/master

function                                             old     new   delta
bb_dump_dump                                        1523    1520      -3

Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
 libbb/dump.c            |  1 -
 testsuite/hexdump.tests | 19 +++++++++++++++++++
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/libbb/dump.c b/libbb/dump.c
index 920f003ef..7a07d6605 100644
--- a/libbb/dump.c
+++ b/libbb/dump.c
@@ -432,7 +432,6 @@ static unsigned char *get(priv_dumper_t *dumper)
 				if (dumper->pub.dump_vflag != DUP) {
 					puts("*");
 				}
-				return NULL;
 			}
 			memset(dumper->get__curp + nread, 0, need);
 			dumper->eaddress = dumper->address + nread;
diff --git a/testsuite/hexdump.tests b/testsuite/hexdump.tests
index 45a0c1300..cfb20187e 100755
--- a/testsuite/hexdump.tests
+++ b/testsuite/hexdump.tests
@@ -15,4 +15,23 @@ testing 'hexdump -C with four NULs' \
 	'' \
 	'\0\0\0\0'
 
+testing "hexdump does not think last padded block matches any full block" \
+	"hexdump -e '1/1 \"%02x|\"1/1 \"%02x!\\n\"'" \
+	"\
+00|00!
+*
+00|  !
+" \
+	'' \
+	'\0\0\0\0\0\0\0\0\0\0\0'
+
+testing "hexdump thinks last full block can match" \
+	"hexdump -e '1/1 \"%02x|\"1/1 \"%02x!\\n\"'" \
+	"\
+00|00!
+*
+" \
+	'' \
+	'\0\0\0\0\0\0\0\0\0\0\0\0'
+
 exit $FAILCOUNT


More information about the busybox-cvs mailing list