diff options
author | ghelmer <ghelmer@FreeBSD.org> | 2011-12-23 01:56:25 +0000 |
---|---|---|
committer | ghelmer <ghelmer@FreeBSD.org> | 2011-12-23 01:56:25 +0000 |
commit | 077423507056d0dc87787828a5c7ef69ab8d13dc (patch) | |
tree | 0d1c8203f58de503d46d84d378bb6f34c0d3f41d /lib/libc/yp | |
parent | 96756edba88e3f7cd10e8516bcb7a15d3d31509c (diff) | |
download | FreeBSD-src-077423507056d0dc87787828a5c7ef69ab8d13dc.zip FreeBSD-src-077423507056d0dc87787828a5c7ef69ab8d13dc.tar.gz |
Handle failures to malloc memory to hold key or val copies.
PR: bin/83348
Diffstat (limited to 'lib/libc/yp')
-rw-r--r-- | lib/libc/yp/xdryp.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/libc/yp/xdryp.c b/lib/libc/yp/xdryp.c index ec2f71a..bb9096b 100644 --- a/lib/libc/yp/xdryp.c +++ b/lib/libc/yp/xdryp.c @@ -82,10 +82,21 @@ xdr_ypresp_all_seq(XDR *xdrs, u_long *objp) 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'; |