Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 23 Dec 2011 01:56:25 +0000 (UTC)
From:      Guy Helmer <ghelmer@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r228826 - head/lib/libc/yp
Message-ID:  <201112230156.pBN1uPs5043040@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ghelmer
Date: Fri Dec 23 01:56:25 2011
New Revision: 228826
URL: http://svn.freebsd.org/changeset/base/228826

Log:
  Handle failures to malloc memory to hold key or val copies.
  
  PR:		bin/83348

Modified:
  head/lib/libc/yp/xdryp.c

Modified: head/lib/libc/yp/xdryp.c
==============================================================================
--- head/lib/libc/yp/xdryp.c	Fri Dec 23 01:39:10 2011	(r228825)
+++ head/lib/libc/yp/xdryp.c	Fri Dec 23 01:56:25 2011	(r228826)
@@ -82,10 +82,21 @@ xdr_ypresp_all_seq(XDR *xdrs, u_long *ob
 		switch (status) {
 		case YP_TRUE:
 			key = (char *)malloc(out.ypresp_all_u.val.key.keydat_len + 1);
+			if (key == NULL) {
+				xdr_free((xdrproc_t)xdr_ypresp_all, &out);
+				*objp = YP_YPERR;
+				return (FALSE);
+			}
 			bcopy(out.ypresp_all_u.val.key.keydat_val, key,
 				out.ypresp_all_u.val.key.keydat_len);
 			key[out.ypresp_all_u.val.key.keydat_len] = '\0';
 			val = (char *)malloc(out.ypresp_all_u.val.val.valdat_len + 1);
+			if (val == NULL) {
+				free(key);
+				xdr_free((xdrproc_t)xdr_ypresp_all, &out);
+				*objp = YP_YPERR;
+				return (FALSE);
+			}
 			bcopy(out.ypresp_all_u.val.val.valdat_val, val,
 				out.ypresp_all_u.val.val.valdat_len);
 			val[out.ypresp_all_u.val.val.valdat_len] = '\0';



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201112230156.pBN1uPs5043040>