diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 1996-05-22 02:08:39 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 1996-05-22 02:08:39 +0000 |
commit | d523a5235dce507a3777959efd572615695e4836 (patch) | |
tree | 8df840862fa1f695d0feefd6eb4d3b2e4be827ae /lib/libc/yp/yp_first.c | |
parent | 7320c7408d45354bdc901639d71064ae9ef156ee (diff) |
repair return values, more checking
Diffstat (limited to 'lib/libc/yp/yp_first.c')
-rw-r--r-- | lib/libc/yp/yp_first.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/libc/yp/yp_first.c b/lib/libc/yp/yp_first.c index 10f16a5fdfb..4e0e6f71137 100644 --- a/lib/libc/yp/yp_first.c +++ b/lib/libc/yp/yp_first.c @@ -1,4 +1,4 @@ -/* $OpenBSD: yp_first.c,v 1.1 1996/04/24 12:56:19 deraadt Exp $ */ +/* $OpenBSD: yp_first.c,v 1.2 1996/05/22 02:08:36 deraadt Exp $ */ /* $NetBSD: yplib.c,v 1.17 1996/02/04 23:26:26 jtc Exp $ */ /* @@ -67,6 +67,11 @@ yp_first(indomain, inmap, outkey, outkeylen, outval, outvallen) struct timeval tv; int r; + if (indomain == NULL || *indomain == '\0' || + strlen(indomain) > YPMAXDOMAIN || inmap == NULL || + *inmap == '\0' || strlen(inmap) > YPMAXMAP) + return YPERR_BADARGS; + *outkey = *outval = NULL; *outkeylen = *outvallen = 0; @@ -82,7 +87,7 @@ again: (void)memset(&yprkv, 0, sizeof yprkv); r = clnt_call(ysd->dom_client, YPPROC_FIRST, - xdr_ypreq_nokey, &yprnk, xdr_ypresp_key_val, &yprkv, tv); + xdr_ypreq_nokey, &yprnk, xdr_ypresp_key_val, &yprkv, tv); if (r != RPC_SUCCESS) { clnt_perror(ysd->dom_client, "yp_first: clnt_call"); ysd->dom_vers = -1; @@ -91,14 +96,14 @@ again: if (!(r = ypprot_err(yprkv.stat))) { *outkeylen = yprkv.key.keydat_len; if ((*outkey = malloc(*outkeylen + 1)) == NULL) - r = RPC_SYSTEMERROR; + r = YPERR_RESRC; else { (void)memcpy(*outkey, yprkv.key.keydat_val, *outkeylen); (*outkey)[*outkeylen] = '\0'; } *outvallen = yprkv.val.valdat_len; if ((*outval = malloc(*outvallen + 1)) == NULL) - r = RPC_SYSTEMERROR; + r = YPERR_RESRC; else { (void)memcpy(*outval, yprkv.val.valdat_val, *outvallen); (*outval)[*outvallen] = '\0'; |