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 for Android: free password hash cracker in your pocket
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1449351173-6915-1-git-send-email-linux@rasmusvillemoes.dk>
Date:	Sat,  5 Dec 2015 22:32:52 +0100
From:	Rasmus Villemoes <linux@...musvillemoes.dk>
To:	Ursula Braun <ursula.braun@...ibm.com>,
	Martin Schwidefsky <schwidefsky@...ibm.com>,
	Heiko Carstens <heiko.carstens@...ibm.com>
Cc:	Rasmus Villemoes <linux@...musvillemoes.dk>,
	linux-s390@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [PATCH] qeth: don't rely on signedness of char

AFAICT, char is unsigned on s390. Relying on that is a little
subtle. The problem here is that if char happens to be signed and
e.g. card->info.mcl_level[2] contains the value -16, the formatted
output will be "fffffff0", thus overflowing card->info.mcl_level
(which has size 5). To help future readers, simply do an explicit mask
so that the value passed to sprintf is in 0-255. If char is indeed
unsigned, gcc should be able to elide the masking.

In any case, the subsequent 0-termination is redundant, since sprintf
has done that.

Signed-off-by: Rasmus Villemoes <linux@...musvillemoes.dk>
---
 drivers/s390/net/qeth_core_main.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/s390/net/qeth_core_main.c b/drivers/s390/net/qeth_core_main.c
index 31ac53fa5cee..84bc4b862fbb 100644
--- a/drivers/s390/net/qeth_core_main.c
+++ b/drivers/s390/net/qeth_core_main.c
@@ -2682,10 +2682,8 @@ void qeth_print_status_message(struct qeth_card *card)
 		 * */
 		if (!card->info.mcl_level[0]) {
 			sprintf(card->info.mcl_level, "%02x%02x",
-				card->info.mcl_level[2],
-				card->info.mcl_level[3]);
-
-			card->info.mcl_level[QETH_MCL_LENGTH] = 0;
+				card->info.mcl_level[2] & 0xff,
+				card->info.mcl_level[3] & 0xff);
 			break;
 		}
 		/* fallthrough */
-- 
2.6.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ