lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20181211152113.8523-2-thomas.preston@codethink.co.uk>
Date:   Tue, 11 Dec 2018 15:21:12 +0000
From:   Thomas Preston <thomas.preston@...ethink.co.uk>
To:     akpm@...ux-foundation.org, pmladek@...e.com,
        andriy.shevchenko@...ux.intel.com, rostedt@...dmis.org,
        geert+renesas@...der.be, corbet@....net, me@...in.cc,
        sergey.senozhatsky@...il.com, linux-kernel@...r.kernel.org
Cc:     Thomas Preston <thomas.preston@...ethink.co.uk>
Subject: [PATCH 1/2] vsprintf: Specify type for union val members

The vsscanf function uses implicit type casting to populate the long
long integers in union val from the obsolete functions simple_strtol()
and simple_strtoll(). However the new functions kstrtol() and kstrtoll()
expect a pointer to the correct type, so we must be explicit about which
type we are using.

Signed-off-by: Thomas Preston <thomas.preston@...ethink.co.uk>
---
 lib/vsprintf.c | 34 +++++++++++++++++-----------------
 1 file changed, 17 insertions(+), 17 deletions(-)

diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index 37a54a6dd594..bbf2ac734711 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -2914,8 +2914,8 @@ int vsscanf(const char *buf, const char *fmt, va_list args)
 	u8 qualifier;
 	unsigned int base;
 	union {
-		long long s;
-		unsigned long long u;
+		long long sll;
+		unsigned long long ull;
 	} val;
 	s16 field_width;
 	bool is_sign;
@@ -3120,11 +3120,11 @@ int vsscanf(const char *buf, const char *fmt, va_list args)
 			break;
 
 		if (is_sign)
-			val.s = qualifier != 'L' ?
+			val.sll = qualifier != 'L' ?
 				simple_strtol(str, &next, base) :
 				simple_strtoll(str, &next, base);
 		else
-			val.u = qualifier != 'L' ?
+			val.ull = qualifier != 'L' ?
 				simple_strtoul(str, &next, base) :
 				simple_strtoull(str, &next, base);
 
@@ -3133,9 +3133,9 @@ int vsscanf(const char *buf, const char *fmt, va_list args)
 				_parse_integer_fixup_radix(str, &base);
 			while (next - str > field_width) {
 				if (is_sign)
-					val.s = div_s64(val.s, base);
+					val.sll = div_s64(val.sll, base);
 				else
-					val.u = div_u64(val.u, base);
+					val.ull = div_u64(val.ull, base);
 				--next;
 			}
 		}
@@ -3143,36 +3143,36 @@ int vsscanf(const char *buf, const char *fmt, va_list args)
 		switch (qualifier) {
 		case 'H':	/* that's 'hh' in format */
 			if (is_sign)
-				*va_arg(args, signed char *) = val.s;
+				*va_arg(args, signed char *) = val.sll;
 			else
-				*va_arg(args, unsigned char *) = val.u;
+				*va_arg(args, unsigned char *) = val.ull;
 			break;
 		case 'h':
 			if (is_sign)
-				*va_arg(args, short *) = val.s;
+				*va_arg(args, short *) = val.sll;
 			else
-				*va_arg(args, unsigned short *) = val.u;
+				*va_arg(args, unsigned short *) = val.ull;
 			break;
 		case 'l':
 			if (is_sign)
-				*va_arg(args, long *) = val.s;
+				*va_arg(args, long *) = val.sll;
 			else
-				*va_arg(args, unsigned long *) = val.u;
+				*va_arg(args, unsigned long *) = val.ull;
 			break;
 		case 'L':
 			if (is_sign)
-				*va_arg(args, long long *) = val.s;
+				*va_arg(args, long long *) = val.sll;
 			else
-				*va_arg(args, unsigned long long *) = val.u;
+				*va_arg(args, unsigned long long *) = val.ull;
 			break;
 		case 'z':
-			*va_arg(args, size_t *) = val.u;
+			*va_arg(args, size_t *) = val.ull;
 			break;
 		default:
 			if (is_sign)
-				*va_arg(args, int *) = val.s;
+				*va_arg(args, int *) = val.sll;
 			else
-				*va_arg(args, unsigned int *) = val.u;
+				*va_arg(args, unsigned int *) = val.ull;
 			break;
 		}
 		num++;
-- 
2.11.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ