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: <20180907074640.27348-2-linux@rasmusvillemoes.dk>
Date:   Fri,  7 Sep 2018 09:46:40 +0200
From:   Rasmus Villemoes <linux@...musvillemoes.dk>
To:     David Howells <dhowells@...hat.com>
Cc:     linux-kernel@...r.kernel.org,
        Andrew Morton <akpm@...ux-foundation.org>,
        Rasmus Villemoes <linux@...musvillemoes.dk>
Subject: [PATCH 2/2] rxrpc: use kmemdup_nul in rxrpc_krb5_decode_principal

Signed-off-by: Rasmus Villemoes <linux@...musvillemoes.dk>
---
This depends on patch 1/2.

 net/rxrpc/key.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/net/rxrpc/key.c b/net/rxrpc/key.c
index e7f6b8823eb6..42f0ca9265c2 100644
--- a/net/rxrpc/key.c
+++ b/net/rxrpc/key.c
@@ -252,11 +252,9 @@ static int rxrpc_krb5_decode_principal(struct krb5_principal *princ,
 		paddedlen = (tmp + 3) & ~3;
 		if (paddedlen > toklen)
 			return -EINVAL;
-		princ->name_parts[loop] = kmalloc(tmp + 1, GFP_KERNEL);
+		princ->name_parts[loop] = kmemdup_nul(xdr, tmp, GFP_KERNEL);
 		if (!princ->name_parts[loop])
 			return -ENOMEM;
-		memcpy(princ->name_parts[loop], xdr, tmp);
-		princ->name_parts[loop][tmp] = 0;
 		toklen -= paddedlen;
 		xdr += paddedlen >> 2;
 	}
@@ -270,11 +268,9 @@ static int rxrpc_krb5_decode_principal(struct krb5_principal *princ,
 	paddedlen = (tmp + 3) & ~3;
 	if (paddedlen > toklen)
 		return -EINVAL;
-	princ->realm = kmalloc(tmp + 1, GFP_KERNEL);
+	princ->realm = kmemdup_nul(xdr, tmp, GFP_KERNEL);
 	if (!princ->realm)
 		return -ENOMEM;
-	memcpy(princ->realm, xdr, tmp);
-	princ->realm[tmp] = 0;
 	toklen -= paddedlen;
 	xdr += paddedlen >> 2;
 
-- 
2.16.4

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ