From c75cd2cb752cdda249dfa228adfc0565c80f3603 Mon Sep 17 00:00:00 2001 From: Matteo Riondato Date: Mon, 4 Feb 2008 07:56:36 +0000 Subject: [PATCH] Fix incorrect handling of malloc failures PR: bin/83369 MFC after: 1 week --- lib/librpcsvc/Makefile | 2 ++ lib/librpcsvc/xcrypt.c | 8 ++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/librpcsvc/Makefile b/lib/librpcsvc/Makefile index 3939a6af24f0..c9674cb068e1 100644 --- a/lib/librpcsvc/Makefile +++ b/lib/librpcsvc/Makefile @@ -29,6 +29,8 @@ SRCS+= ${GENSRCS} ${OTHERSRCS} ${SECRPCSRCS} CLEANFILES+= ${GENSRCS} +WARNS?= 2 + .include .SUFFIXES: .x _xdr.c 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);