diff options
author | jimharris <jimharris@FreeBSD.org> | 2012-01-26 15:23:45 +0000 |
---|---|---|
committer | jimharris <jimharris@FreeBSD.org> | 2012-01-26 15:23:45 +0000 |
commit | bcd0e15cf642d6e5bf78ee585ad282b0e3061864 (patch) | |
tree | 4b7b6096856cdeb36fcba0adf3f4d121a52cce21 /lib/libc/yp/yplib.c | |
parent | 0cf3f853641c2ededc243c9f2139ac6a0b681fe4 (diff) | |
parent | a479ceccdf3646c7bc3ff60796c765650b3ffc03 (diff) | |
download | FreeBSD-src-bcd0e15cf642d6e5bf78ee585ad282b0e3061864.zip FreeBSD-src-bcd0e15cf642d6e5bf78ee585ad282b0e3061864.tar.gz |
Rebase user/jimharris/isci branch from head.
Diffstat (limited to 'lib/libc/yp/yplib.c')
-rw-r--r-- | lib/libc/yp/yplib.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/lib/libc/yp/yplib.c b/lib/libc/yp/yplib.c index 87d16dd..3dfc0aa 100644 --- a/lib/libc/yp/yplib.c +++ b/lib/libc/yp/yplib.c @@ -331,6 +331,8 @@ _yp_dobind(char *dom, struct dom_binding **ypdb) if (ysd == NULL) { ysd = (struct dom_binding *)malloc(sizeof *ysd); + if (ysd == NULL) + return (YPERR_RESRC); bzero((char *)ysd, sizeof *ysd); ysd->dom_socket = -1; ysd->dom_vers = 0; @@ -683,11 +685,18 @@ yp_match(char *indomain, char *inmap, const char *inkey, int inkeylen, */ *outvallen = yprv.val.valdat_len; *outval = (char *)malloc(*outvallen+1); + if (*outval == NULL) { + _yp_unbind(ysd); + *outvallen = 0; + YPUNLOCK(); + return (YPERR_RESRC); + } bcopy(yprv.val.valdat_val, *outval, *outvallen); (*outval)[*outvallen] = '\0'; YPUNLOCK(); return (0); } + _yp_unbind(ysd); #endif again: @@ -713,6 +722,13 @@ again: if (!(r = ypprot_err(yprv.stat))) { *outvallen = yprv.val.valdat_len; *outval = (char *)malloc(*outvallen+1); + if (*outval == NULL) { + _yp_unbind(ysd); + *outvallen = 0; + xdr_free((xdrproc_t)xdr_ypresp_val, &yprv); + YPUNLOCK(); + return (YPERR_RESRC); + } bcopy(yprv.val.valdat_val, *outval, *outvallen); (*outval)[*outvallen] = '\0'; #ifdef YPMATCHCACHE @@ -791,10 +807,25 @@ again: if (!(r = ypprot_err(yprkv.stat))) { *outkeylen = yprkv.key.keydat_len; *outkey = (char *)malloc(*outkeylen+1); + if (*outkey == NULL) { + _yp_unbind(ysd); + *outkeylen = 0; + xdr_free((xdrproc_t)xdr_ypresp_key_val, &yprkv); + YPUNLOCK(); + return (YPERR_RESRC); + } bcopy(yprkv.key.keydat_val, *outkey, *outkeylen); (*outkey)[*outkeylen] = '\0'; *outvallen = yprkv.val.valdat_len; *outval = (char *)malloc(*outvallen+1); + if (*outval == NULL) { + free(*outkey); + _yp_unbind(ysd); + *outkeylen = *outvallen = 0; + xdr_free((xdrproc_t)xdr_ypresp_key_val, &yprkv); + YPUNLOCK(); + return (YPERR_RESRC); + } bcopy(yprkv.val.valdat_val, *outval, *outvallen); (*outval)[*outvallen] = '\0'; } @@ -851,10 +882,25 @@ again: if (!(r = ypprot_err(yprkv.stat))) { *outkeylen = yprkv.key.keydat_len; *outkey = (char *)malloc(*outkeylen+1); + if (*outkey == NULL) { + _yp_unbind(ysd); + *outkeylen = 0; + xdr_free((xdrproc_t)xdr_ypresp_key_val, &yprkv); + YPUNLOCK(); + return (YPERR_RESRC); + } bcopy(yprkv.key.keydat_val, *outkey, *outkeylen); (*outkey)[*outkeylen] = '\0'; *outvallen = yprkv.val.valdat_len; *outval = (char *)malloc(*outvallen+1); + if (*outval == NULL) { + free(*outkey); + _yp_unbind(ysd); + *outkeylen = *outvallen = 0; + xdr_free((xdrproc_t)xdr_ypresp_key_val, &yprkv); + YPUNLOCK(); + return (YPERR_RESRC); + } bcopy(yprkv.val.valdat_val, *outval, *outvallen); (*outval)[*outvallen] = '\0'; } |