From e86d3565bebed9902d5c7ac81c0158c750c0cbdf Mon Sep 17 00:00:00 2001 From: Matteo Riondato Date: Sun, 30 Mar 2008 19:57:23 +0000 Subject: [PATCH] MFC rev. 1.6 Fix incorrect handling of malloc failures PR: bin/83369 --- lib/librpcsvc/xcrypt.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/librpcsvc/xcrypt.c b/lib/librpcsvc/xcrypt.c index ed6cbefcc14e..7a310d3d10f2 100644 --- a/lib/librpcsvc/xcrypt.c +++ b/lib/librpcsvc/xcrypt.c @@ -67,7 +67,9 @@ xencrypt(secret, passwd) int len; len = strlen(secret) / 2; - buf = malloc((unsigned)len); + if ((buf = malloc((unsigned)len)) == NULL) { + return(0); + } hex2bin(len, secret, buf); passwd2des(passwd, key); @@ -100,7 +102,9 @@ xdecrypt(secret, passwd) int len; len = strlen(secret) / 2; - buf = malloc((unsigned)len); + if ((buf = malloc((unsigned)len)) == NULL) { + return(0); + } hex2bin(len, secret, buf); passwd2des(passwd, key);