summaryrefslogtreecommitdiff
path: root/lib/libc
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1996-05-22 02:08:39 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1996-05-22 02:08:39 +0000
commitd523a5235dce507a3777959efd572615695e4836 (patch)
tree8df840862fa1f695d0feefd6eb4d3b2e4be827ae /lib/libc
parent7320c7408d45354bdc901639d71064ae9ef156ee (diff)
repair return values, more checking
Diffstat (limited to 'lib/libc')
-rw-r--r--lib/libc/yp/xdr_keydat.c4
-rw-r--r--lib/libc/yp/xdr_valdat.c4
-rw-r--r--lib/libc/yp/yp_all.c24
-rw-r--r--lib/libc/yp/yp_bind.c15
-rw-r--r--lib/libc/yp/yp_first.c13
-rw-r--r--lib/libc/yp/yp_maplist.c4
-rw-r--r--lib/libc/yp/yp_master.c11
-rw-r--r--lib/libc/yp/yp_order.c9
-rw-r--r--lib/libc/yp/ypmatch_cache.c27
9 files changed, 70 insertions, 41 deletions
diff --git a/lib/libc/yp/xdr_keydat.c b/lib/libc/yp/xdr_keydat.c
index a7cb84fa603..62daf305705 100644
--- a/lib/libc/yp/xdr_keydat.c
+++ b/lib/libc/yp/xdr_keydat.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: xdr_keydat.c,v 1.1 1996/04/24 12:55:43 deraadt Exp $ */
+/* $OpenBSD: xdr_keydat.c,v 1.2 1996/05/22 02:08:32 deraadt Exp $ */
/* $NetBSD: xdryp.c,v 1.10 1996/02/04 23:26:21 jtc Exp $ */
/*
@@ -54,5 +54,5 @@ XDR *xdrs;
keydat *objp;
{
return xdr_bytes(xdrs, (char **)&objp->keydat_val,
- (u_int *)&objp->keydat_len, YPMAXRECORD);
+ (u_int *)&objp->keydat_len, YPMAXRECORD);
}
diff --git a/lib/libc/yp/xdr_valdat.c b/lib/libc/yp/xdr_valdat.c
index 35350ab7d69..cf4c2617406 100644
--- a/lib/libc/yp/xdr_valdat.c
+++ b/lib/libc/yp/xdr_valdat.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: xdr_valdat.c,v 1.1 1996/04/24 12:55:47 deraadt Exp $ */
+/* $OpenBSD: xdr_valdat.c,v 1.2 1996/05/22 02:08:34 deraadt Exp $ */
/* $NetBSD: xdryp.c,v 1.10 1996/02/04 23:26:21 jtc Exp $ */
/*
@@ -54,5 +54,5 @@ XDR *xdrs;
valdat *objp;
{
return xdr_bytes(xdrs, (char **)&objp->valdat_val,
- (u_int *)&objp->valdat_len, YPMAXRECORD);
+ (u_int *)&objp->valdat_len, YPMAXRECORD);
}
diff --git a/lib/libc/yp/yp_all.c b/lib/libc/yp/yp_all.c
index 2a7f5eede5d..51503c49cfc 100644
--- a/lib/libc/yp/yp_all.c
+++ b/lib/libc/yp/yp_all.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: yp_all.c,v 1.1 1996/04/24 12:56:16 deraadt Exp $ */
+/* $OpenBSD: yp_all.c,v 1.2 1996/05/22 02:08:35 deraadt Exp $ */
/* $NetBSD: yplib.c,v 1.17 1996/02/04 23:26:26 jtc Exp $ */
/*
@@ -80,15 +80,15 @@ u_long *objp;
size = out.ypresp_all_u.val.key.keydat_len;
if ((key = malloc(size + 1)) != NULL) {
(void)memcpy(key,
- out.ypresp_all_u.val.key.keydat_val,
- size);
+ out.ypresp_all_u.val.key.keydat_val,
+ size);
key[size] = '\0';
}
size = out.ypresp_all_u.val.val.valdat_len;
if ((val = malloc(size + 1)) != NULL) {
(void)memcpy(val,
- out.ypresp_all_u.val.val.valdat_val,
- size);
+ out.ypresp_all_u.val.val.valdat_val,
+ size);
val[size] = '\0';
}
else {
@@ -100,10 +100,9 @@ u_long *objp;
if (key == NULL || val == NULL)
return FALSE;
- r = (*ypresp_allfn)(status,
- key, out.ypresp_all_u.val.key.keydat_len,
- val, out.ypresp_all_u.val.val.valdat_len,
- ypresp_data);
+ r = (*ypresp_allfn)(status, key,
+ out.ypresp_all_u.val.key.keydat_len, val,
+ out.ypresp_all_u.val.val.valdat_len, ypresp_data);
*objp = status;
free(key);
free(val);
@@ -136,6 +135,11 @@ yp_all(indomain, inmap, incallback)
int clnt_sock;
int r = 0;
+ if (indomain == NULL || *indomain == '\0' ||
+ strlen(indomain) > YPMAXDOMAIN || inmap == NULL ||
+ *inmap == '\0' || strlen(inmap) > YPMAXMAP || incallback == NULL)
+ return YPERR_BADARGS;
+
if (_yp_dobind(indomain, &ysd) != 0)
return YPERR_DOMAIN;
@@ -156,7 +160,7 @@ yp_all(indomain, inmap, incallback)
ypresp_data = (void *) incallback->data;
(void) clnt_call(clnt, YPPROC_ALL,
- xdr_ypreq_nokey, &yprnk, xdr_ypresp_all_seq, &status, tv);
+ xdr_ypreq_nokey, &yprnk, xdr_ypresp_all_seq, &status, tv);
clnt_destroy(clnt);
if(status != YP_FALSE)
r = ypprot_err(status);
diff --git a/lib/libc/yp/yp_bind.c b/lib/libc/yp/yp_bind.c
index eda85e693f0..5a643bb134b 100644
--- a/lib/libc/yp/yp_bind.c
+++ b/lib/libc/yp/yp_bind.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: yp_bind.c,v 1.1 1996/04/24 12:56:18 deraadt Exp $ */
+/* $OpenBSD: yp_bind.c,v 1.2 1996/05/22 02:08:35 deraadt Exp $ */
/* $NetBSD: yplib.c,v 1.17 1996/02/04 23:26:26 jtc Exp $ */
/*
@@ -144,9 +144,9 @@ again:
goto again;
}
(void)memset(&ysd->dom_server_addr, 0,
- sizeof ysd->dom_server_addr);
+ sizeof ysd->dom_server_addr);
ysd->dom_server_addr.sin_len =
- sizeof(struct sockaddr_in);
+ sizeof(struct sockaddr_in);
ysd->dom_server_addr.sin_family = AF_INET;
bn = &ybr.ypbind_resp_u.ypbind_bindinfo;
memcpy(&ysd->dom_server_addr.sin_port,
@@ -156,7 +156,6 @@ again:
memcpy(&ysd->dom_server_addr.sin_addr,
&bn->ypbind_binding_addr,
sizeof(ysd->dom_server_addr.sin_addr));
-
ysd->dom_server_port = ysd->dom_server_addr.sin_port;
(void)close(fd);
@@ -179,7 +178,7 @@ trynet:
clnt_sock = RPC_ANYSOCK;
client = clnttcp_create(&clnt_sin, YPBINDPROG, YPBINDVERS,
- &clnt_sock, 0, 0);
+ &clnt_sock, 0, 0);
if (client == NULL) {
clnt_pcreateerror("clnttcp_create");
if (new)
@@ -189,7 +188,7 @@ trynet:
tv.tv_sec = _yplib_timeout;
tv.tv_usec = 0;
r = clnt_call(client, YPBINDPROC_DOMAIN, xdr_domainname,
- &dom, xdr_ypbind_resp, &ypbr, tv);
+ &dom, xdr_ypbind_resp, &ypbr, tv);
if (r != RPC_SUCCESS) {
if (new == 0 || count)
fprintf(stderr,
@@ -203,7 +202,7 @@ trynet:
clnt_destroy(client);
(void)memset(&ysd->dom_server_addr, 0,
- sizeof ysd->dom_server_addr);
+ sizeof ysd->dom_server_addr);
ysd->dom_server_addr.sin_len = sizeof(struct sockaddr_in);
ysd->dom_server_addr.sin_family = AF_INET;
bn = &ypbr.ypbind_resp_u.ypbind_bindinfo;
@@ -224,7 +223,7 @@ gotit:
clnt_destroy(ysd->dom_client);
ysd->dom_socket = RPC_ANYSOCK;
ysd->dom_client = clntudp_create(&ysd->dom_server_addr,
- YPPROG, YPVERS, tv, &ysd->dom_socket);
+ YPPROG, YPVERS, tv, &ysd->dom_socket);
if (ysd->dom_client == NULL) {
clnt_pcreateerror("clntudp_create");
ysd->dom_vers = -1;
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';
diff --git a/lib/libc/yp/yp_maplist.c b/lib/libc/yp/yp_maplist.c
index 5932ea9612c..7180bc7f20a 100644
--- a/lib/libc/yp/yp_maplist.c
+++ b/lib/libc/yp/yp_maplist.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: yp_maplist.c,v 1.1 1996/04/24 12:56:22 deraadt Exp $ */
+/* $OpenBSD: yp_maplist.c,v 1.2 1996/05/22 02:08:37 deraadt Exp $ */
/* $NetBSD: yplib.c,v 1.17 1996/02/04 23:26:26 jtc Exp $ */
/*
@@ -72,7 +72,7 @@ again:
memset(&ypml, 0, sizeof ypml);
r = clnt_call(ysd->dom_client, YPPROC_MAPLIST,
- xdr_domainname, &indomain, xdr_ypresp_maplist, &ypml, tv);
+ xdr_domainname, &indomain, xdr_ypresp_maplist, &ypml, tv);
if (r != RPC_SUCCESS) {
clnt_perror(ysd->dom_client, "yp_maplist: clnt_call");
ysd->dom_vers = -1;
diff --git a/lib/libc/yp/yp_master.c b/lib/libc/yp/yp_master.c
index 181a397a159..dc4d81dc51b 100644
--- a/lib/libc/yp/yp_master.c
+++ b/lib/libc/yp/yp_master.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: yp_master.c,v 1.1 1996/04/24 12:56:25 deraadt Exp $ */
+/* $OpenBSD: yp_master.c,v 1.2 1996/05/22 02:08:37 deraadt Exp $ */
/* $NetBSD: yplib.c,v 1.17 1996/02/04 23:26:26 jtc Exp $ */
/*
@@ -64,6 +64,11 @@ yp_master(indomain, inmap, outname)
struct timeval tv;
int r;
+ if (indomain == NULL || *indomain == '\0' ||
+ strlen(indomain) > YPMAXDOMAIN || inmap == NULL ||
+ *inmap == '\0' || strlen(inmap) > YPMAXMAP || outname == NULL)
+ return YPERR_BADARGS;
+
again:
if (_yp_dobind(indomain, &ysd) != 0)
return YPERR_DOMAIN;
@@ -77,7 +82,7 @@ again:
(void)memset(&yprm, 0, sizeof yprm);
r = clnt_call(ysd->dom_client, YPPROC_MASTER,
- xdr_ypreq_nokey, &yprnk, xdr_ypresp_master, &yprm, tv);
+ xdr_ypreq_nokey, &yprnk, xdr_ypresp_master, &yprm, tv);
if (r != RPC_SUCCESS) {
clnt_perror(ysd->dom_client, "yp_master: clnt_call");
ysd->dom_vers = -1;
@@ -85,7 +90,7 @@ again:
}
if (!(r = ypprot_err(yprm.stat))) {
if ((*outname = strdup(yprm.peer)) == NULL)
- r = RPC_SYSTEMERROR;
+ r = YPERR_RESRC;
}
xdr_free(xdr_ypresp_master, (char *) &yprm);
_yp_unbind(ysd);
diff --git a/lib/libc/yp/yp_order.c b/lib/libc/yp/yp_order.c
index fab5c2524d5..33f45d732f9 100644
--- a/lib/libc/yp/yp_order.c
+++ b/lib/libc/yp/yp_order.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: yp_order.c,v 1.2 1996/04/25 00:53:49 deraadt Exp $ */
+/* $OpenBSD: yp_order.c,v 1.3 1996/05/22 02:08:38 deraadt Exp $ */
/* $NetBSD: yplib.c,v 1.17 1996/02/04 23:26:26 jtc Exp $ */
/*
@@ -64,6 +64,11 @@ yp_order(indomain, inmap, outorder)
struct timeval tv;
int r = 0;
+ if (indomain == NULL || *indomain == '\0' ||
+ strlen(indomain) > YPMAXDOMAIN || inmap == NULL ||
+ *inmap == '\0' || strlen(inmap) > YPMAXMAP || outorder == NULL)
+ return YPERR_BADARGS;
+
again:
if (_yp_dobind(indomain, &ysd) != 0)
return YPERR_DOMAIN;
@@ -77,7 +82,7 @@ again:
(void)memset(&ypro, 0, sizeof ypro);
r = clnt_call(ysd->dom_client, YPPROC_ORDER,
- xdr_ypreq_nokey, &yprnk, xdr_ypresp_order, &ypro, tv);
+ xdr_ypreq_nokey, &yprnk, xdr_ypresp_order, &ypro, tv);
/*
* XXX
* NIS+ YP emulation package does not impliment YPPROC_ORDER
diff --git a/lib/libc/yp/ypmatch_cache.c b/lib/libc/yp/ypmatch_cache.c
index 16ad9016148..a08530ede57 100644
--- a/lib/libc/yp/ypmatch_cache.c
+++ b/lib/libc/yp/ypmatch_cache.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ypmatch_cache.c,v 1.1 1996/04/24 12:56:31 deraadt Exp $ */
+/* $OpenBSD: ypmatch_cache.c,v 1.2 1996/05/22 02:08:38 deraadt Exp $ */
/* $NetBSD: yplib.c,v 1.17 1996/02/04 23:26:26 jtc Exp $ */
/*
@@ -166,6 +166,12 @@ yp_match(indomain, inmap, inkey, inkeylen, outval, outvallen)
struct ypreq_key yprk;
int r;
+ if (indomain == NULL || *indomain == '\0' ||
+ strlen(indomain) > YPMAXDOMAIN || inmap == NULL ||
+ *inmap == '\0' || strlen(inmap) > YPMAXMAP ||
+ inkey == NULL || inkeylen == 0)
+ return YPERR_BADARGS;
+
*outval = NULL;
*outvallen = 0;
@@ -175,7 +181,7 @@ again:
#ifdef YPMATCHCACHE
if (!strcmp(_yp_domain, indomain) && ypmatch_find(inmap, inkey,
- inkeylen, &yprv.val.valdat_val, &yprv.val.valdat_len)) {
+ inkeylen, &yprv.val.valdat_val, &yprv.val.valdat_len)) {
*outvallen = yprv.val.valdat_len;
if ((*outval = malloc(*outvallen + 1)) == NULL) {
_yp_unbind(ysd);
@@ -199,7 +205,7 @@ again:
memset(&yprv, 0, sizeof yprv);
r = clnt_call(ysd->dom_client, YPPROC_MATCH,
- xdr_ypreq_key, &yprk, xdr_ypresp_val, &yprv, tv);
+ xdr_ypreq_key, &yprk, xdr_ypresp_val, &yprv, tv);
if (r != RPC_SUCCESS) {
clnt_perror(ysd->dom_client, "yp_match: clnt_call");
ysd->dom_vers = -1;
@@ -216,8 +222,8 @@ again:
#ifdef YPMATCHCACHE
if (strcmp(_yp_domain, indomain) == 0)
if (!ypmatch_add(inmap, inkey, inkeylen,
- *outval, *outvallen))
- r = RPC_SYSTEMERROR;
+ *outval, *outvallen))
+ r = YPERR_RESRC;
#endif
}
out:
@@ -243,6 +249,11 @@ yp_next(indomain, inmap, inkey, inkeylen, 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;
@@ -260,7 +271,7 @@ again:
(void)memset(&yprkv, 0, sizeof yprkv);
r = clnt_call(ysd->dom_client, YPPROC_NEXT,
- xdr_ypreq_key, &yprk, xdr_ypresp_key_val, &yprkv, tv);
+ xdr_ypreq_key, &yprk, xdr_ypresp_key_val, &yprkv, tv);
if (r != RPC_SUCCESS) {
clnt_perror(ysd->dom_client, "yp_next: clnt_call");
ysd->dom_vers = -1;
@@ -269,14 +280,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';