lib/vsprintf.c: wrong conversion function used
Subsystems (2)
PATCH 1/1 lib/vsprintf.c: wrong conversion function used
From: Swen Schillig <[email protected]>
The macro define_strict_strtoux() is using the simple_strtoul () function as opposed to the simple_strtoull() function. This leads to false conversions on non-64bit
machines (here 31bit System z).
The following patch fixes the issue introduced by
commit 06b2a76d25d3cfbd14680021c1d356c91be6904e
Author: Yi Yang <[email protected]> Date: Fri Feb 8 04:21:57 2008 -0800
--- lib/vsprintf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/vsprintf.c +1 -1
@@ -220,7 +220,7 @@ int strict_strtou##type(const char *cp,if (len ==0 ) \return -EINVAL ; \ \ - val =simple_strtoul (cp, &tail, base); \ + val =simple_strtoull (cp, &tail, base); \if ((*tail =='\0' ) || \ ((len == (size_t )(tail - cp) +1 ) && (*tail =='\n' ))) {\ *res = val; \
Swen, your fix is just partly correct, it'll has a big problem for strict_strtoul, because val is of long type, but you patch will result in long long return type, the below patch is a correct fix.
--- vsprintf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/vsprintf.c +1 -1
@@ -220,7 +220,7 @@ int strict_strtou##type(const char *cp, unsigned int base, valtype *res)\if (len ==0 ) \return -EINVAL ; \ \ - val =simple_strtoul (cp, &tail, base); \ + val = simple_strtou##type(cp, &tail, base); \ if ((*tail == '\0') || \ ((len == (size_t)(tail - cp) + 1) && (*tail == '\n'))) {\ *res = val; \
Quoted 31 lines · Swen Schillig
From: Swen Schillig <[email protected]>
The macro
define_strict_strtoux()is using thesimple_strtoul() function as opposed to thesimple_strtoull()function. This leads to false conversions on non-64bit
machines (here 31bit System z).The following patch fixes the issue introduced by
commit
06b2a76d25d3cfbd14680021c1d356c91be6904eAuthor: Yi Yang <[email protected]> Date: Fri Feb 8 04:21:57 2008 -0800Signed-off-by Swen Schillig <[email protected]>--- lib/vsprintf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)Index:
HEAD/lib/vsprintf.c
===================================================================lib/vsprintf.c +1
-1@@ -220,7 +220,7 @@ int strict_strtou##type(const char *cp,if (len ==0 ) \return -EINVAL ; \ \ - val =simple_strtoul (cp, &tail, base); \ + val =simple_strtoull (cp, &tail, base); \if ((*tail =='\0' ) || \ ((len == (size_t )(tail - cp) +1 ) && (*tail =='\n' ))) {\ *res = val; \