From a165603d24dc3b5080859abfa834d092f456489d Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Wed, 19 Jul 2017 10:43:10 +0100 Subject: od_bloaty: fix floating point output Currently od_bloaty does this: $ /bin/echo -en '\x00\x00\x00\x00\x00\x00\x00\x00' | busybox od -f od: invalid character 'F' in type string 'fF' $ /bin/echo -en '\x00\x00\x00\x00\x00\x00\x00\x00' | busybox od -t fD od: invalid character 'D' in type string 'fD' $ /bin/echo -en '\x00\x00\x00\x00\x00\x00\x00\x00' | busybox od -t f 0000000 0000010 The first two occur because the alphabetic length specifier isn't being properly skipped. The third is due to the empty length specifier being treated as alphabetic so we fall off the end of the FDL_sizeof array with undetermined consequences. Coreutils defaults to printing a double in this case. With this patch the output is: $ /bin/echo -en '\x00\x00\x00\x00\x00\x00\x00\x00' | ./busybox od -f 0000000 0.0000000e+00 0.0000000e+00 0000010 $ /bin/echo -en '\x00\x00\x00\x00\x00\x00\x00\x00' | ./busybox od -t fD 0000000 0.000000000000000e+00 0000010 $ /bin/echo -en '\x00\x00\x00\x00\x00\x00\x00\x00' | ./busybox od -t f 0000000 0.000000000000000e+00 0000010 I guess nobody uses BusyBox od to print floating point numbers. Signed-off-by: Ron Yorston Signed-off-by: Denys Vlasenko --- testsuite/od.tests | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'testsuite') diff --git a/testsuite/od.tests b/testsuite/od.tests index 7a9da3e..0880e0d 100755 --- a/testsuite/od.tests +++ b/testsuite/od.tests @@ -16,6 +16,16 @@ testing "od -b" \ "" "HELLO" SKIP= +optional DESKTOP +testing "od -f" \ + "od -f" \ +"\ +0000000 0.0000000e+00 0.0000000e+00 +0000010 +" \ + "" "\x00\x00\x00\x00\x00\x00\x00\x00" +SKIP= + optional DESKTOP LONG_OPTS testing "od -b --traditional" \ "od -b --traditional" \ -- cgit v1.1