diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 1995-10-24 14:47:12 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 1995-10-24 14:47:12 +0000 |
commit | 2ac10bb118af4f0713b2a46a13b12db12fc75197 (patch) | |
tree | 2f644d62aedfe0e725ff27116f78b4d57c64acc5 | |
parent | 3fa7164a950a254f2bb8640bfe2670c83d6159ea (diff) |
new email address :-)
never forget to call _yp_unbind() if we need to bail out
-rw-r--r-- | lib/libc/yp/xdryp.c | 2 | ||||
-rw-r--r-- | lib/libc/yp/yplib.c | 27 |
2 files changed, 18 insertions, 11 deletions
diff --git a/lib/libc/yp/xdryp.c b/lib/libc/yp/xdryp.c index 72cfb836ea4..1145b1bb4fd 100644 --- a/lib/libc/yp/xdryp.c +++ b/lib/libc/yp/xdryp.c @@ -1,7 +1,7 @@ /* $NetBSD: xdryp.c,v 1.9 1995/07/14 21:04:17 christos Exp $ */ /* - * Copyright (c) 1992, 1993 Theo de Raadt <deraadt@fsa.ca> + * Copyright (c) 1992, 1993 Theo de Raadt <deraadt@theos.com> * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/lib/libc/yp/yplib.c b/lib/libc/yp/yplib.c index 720c02a794b..0c1a59b609c 100644 --- a/lib/libc/yp/yplib.c +++ b/lib/libc/yp/yplib.c @@ -1,7 +1,7 @@ /* $NetBSD: yplib.c,v 1.16 1995/07/14 21:04:24 christos Exp $ */ /* - * Copyright (c) 1992, 1993 Theo de Raadt <deraadt@fsa.ca> + * Copyright (c) 1992, 1993 Theo de Raadt <deraadt@theos.com> * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -408,7 +408,7 @@ yp_match(indomain, inmap, inkey, inkeylen, outval, outvallen) struct ypresp_val yprv; struct timeval tv; struct ypreq_key yprk; - int r; + int r = 0; *outval = NULL; *outvallen = 0; @@ -421,11 +421,13 @@ again: if (!strcmp(_yp_domain, indomain) && ypmatch_find(inmap, inkey, inkeylen, &yprv.valdat.dptr, &yprv.valdat.dsize)) { *outvallen = yprv.valdat.dsize; - if ((*outval = malloc(*outvallen + 1)) == NULL) - return YPERR_YPERR; + if ((*outval = malloc(*outvallen + 1)) == NULL) { + r = YPERR_YPERR; + goto out; + } (void)memcpy(*outval, yprv.valdat.dptr, *outvallen); (*outval)[*outvallen] = '\0'; - return 0; + goto out; } #endif @@ -448,8 +450,10 @@ again: } if (!(r = ypprot_err(yprv.status))) { *outvallen = yprv.valdat.dsize; - if ((*outval = malloc(*outvallen + 1)) == NULL) - return YPERR_YPERR; + if ((*outval = malloc(*outvallen + 1)) == NULL) { + r = YPERR_YPERR; + goto out; + } (void)memcpy(*outval, yprv.valdat.dptr, *outvallen); (*outval)[*outvallen] = '\0'; #ifdef YPMATCHCACHE @@ -459,6 +463,7 @@ again: r = RPC_SYSTEMERROR; #endif } +out: xdr_free(xdr_ypresp_val, (char *) &yprv); _yp_unbind(ysd); return r; @@ -607,6 +612,7 @@ yp_all(indomain, inmap, incallback) CLIENT *clnt; u_long status; int clnt_sock; + int r = 0; if (_yp_dobind(indomain, &ysd) != 0) return YPERR_DOMAIN; @@ -619,7 +625,8 @@ yp_all(indomain, inmap, incallback) clnt = clnttcp_create(&clnt_sin, YPPROG, YPVERS, &clnt_sock, 0, 0); if (clnt == NULL) { printf("clnttcp_create failed\n"); - return YPERR_PMAP; + r = YPERR_PMAP; + goto out; } yprnk.domain = indomain; yprnk.map = inmap; @@ -629,13 +636,13 @@ yp_all(indomain, inmap, incallback) (void) clnt_call(clnt, YPPROC_ALL, xdr_ypreq_nokey, &yprnk, xdr_ypresp_all_seq, &status, tv); clnt_destroy(clnt); - /* not really needed... */ xdr_free(xdr_ypresp_all_seq, (char *) &status); +out: _yp_unbind(ysd); if (status != YP_FALSE) return ypprot_err(status); - return 0; + return r; } int |