Handle failures to malloc memory to hold key or val copies.

PR:		bin/83348
This commit is contained in:
Guy Helmer 2011-12-23 01:56:25 +00:00
parent e050eaa32a
commit 53fc6e1e4d
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=228826

View File

@ -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';