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';
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to