]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
test/bioprinttest.c: fix sloppy length modifier usage in int_data
authorEugene Syromiatnikov <esyr@openssl.org>
Fri, 29 Aug 2025 17:39:53 +0000 (19:39 +0200)
committerNeil Horman <nhorman@openssl.org>
Fri, 29 Aug 2025 21:20:26 +0000 (17:20 -0400)
Some test vectors used in int_data have mismatching (or, more
spercifically) missing length modifiers in conversion specifiers;
most of the time it has gone unnoticed, but on some architectures where
64-bit arguments supplied differently (sugh as mips and armv7) it led
to garbage being retrieved instead of the expected values.  Fix it
by properly providing proper length modifiers.

Fixes: 9deaf8383338 "test/bioprinttest.c: add some checks for integer and string printing"
Signed-off-by: Eugene Syromiatnikov <esyr@openssl.org>
Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/28388)

test/bioprinttest.c

index f62304e381bd0fb3e5dacf68049f97927ede9ebd..29acddac4056dc936f79661ee7957d497ab89cf8 100644 (file)
@@ -159,7 +159,7 @@ static const struct int_data {
     { { .hh = 0x95 }, AT_CHAR, "%#06hhi", "-00107" },
     { { .hh = 0x4 }, AT_CHAR, "%# hhd", " 4" },
     { { .hh = 0x3 }, AT_CHAR, "%# hhu", "3" },
-    { { .hh = 0x0 }, AT_CHAR, "%02x", "00" },
+    { { .hh = 0x0 }, AT_CHAR, "%02hhx", "00" },
     { { .h = 0 }, AT_SHORT, "|%.0hd|", "||" },
     { { .h = 0 }, AT_SHORT, "|%.hu|", "||" },
     { { .h = 0 }, AT_SHORT, "|%#.ho|", "|0|" },
@@ -215,16 +215,16 @@ static const struct int_data {
     { { .i = 0x1337 }, AT_INT, "%4294967302.x", "",
       .skip_libc_check = true, .exp_ret = -1 },
     { { .i = 0xbeeface }, AT_INT, "%#+-12.1d", "+200211150  " },
-    { { .l = 0 }, AT_LONG, "%%%#.0o%%", "%0%" },
-    { { .l = 0 }, AT_LONG, "%%%.0o%%", "%%" },
-    { { .l = 0 }, AT_LONG, "%%%-.0o%%", "%%" },
-    { { .l = 0xfacefed }, AT_LONG, "%#-1.14d", "00000262991853" },
-    { { .l = 0xdefaced }, AT_LONG, "%#+-014.11i", "+00233811181  " },
-    { { .l = 0xfacade }, AT_LONG, "%#0.14o", "00000076545336" },
-    { { .l = 0 }, AT_LONG, "%#0.14o", "00000000000000" },
-    { { .l = 0xfacade }, AT_LONG, "%#0.14x", "0x00000000facade" },
-    { { .ll = 0 }, AT_LLONG, "#%#.0x#", "##" },
-    { { .ll = 0 }, AT_LLONG, "#%.0x#", "##" },
+    { { .l = 0 }, AT_LONG, "%%%#.0lo%%", "%0%" },
+    { { .l = 0 }, AT_LONG, "%%%.0lo%%", "%%" },
+    { { .l = 0 }, AT_LONG, "%%%-.0lo%%", "%%" },
+    { { .l = 0xfacefed }, AT_LONG, "%#-1.14ld", "00000262991853" },
+    { { .l = 0xdefaced }, AT_LONG, "%#+-014.11li", "+00233811181  " },
+    { { .l = 0xfacade }, AT_LONG, "%#0.14lo", "00000076545336" },
+    { { .l = 0 }, AT_LONG, "%#0.14lo", "00000000000000" },
+    { { .l = 0xfacade }, AT_LONG, "%#0.14lx", "0x00000000facade" },
+    { { .ll = 0 }, AT_LLONG, "#%#.0llx#", "##" },
+    { { .ll = 0 }, AT_LLONG, "#%.0llx#", "##" },
     { { .ll = 0xffffFFFFffffFFFFULL }, AT_LLONG, "%#-032llo",
       "01777777777777777777777         " },
     { { .ll = 0xbadc0deddeadfaceULL }, AT_LLONG, "%022lld",