Use a constant struct timeval for yp timeouts instead of creating
a new struct timeval in each yp function at runtime. Check arguments and return YPERR_BADARGS if invalid.
This commit is contained in:
parent
2635a9c602
commit
0724069f60
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: yp_all.c,v 1.1 1996/05/14 23:37:30 jtc Exp $ */
|
/* $NetBSD: yp_all.c,v 1.2 1996/05/18 19:01:19 jtc Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1992, 1993 Theo de Raadt <deraadt@fsa.ca>
|
* Copyright (c) 1992, 1993 Theo de Raadt <deraadt@fsa.ca>
|
||||||
@ -32,14 +32,14 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#if defined(LIBC_SCCS) && !defined(lint)
|
#if defined(LIBC_SCCS) && !defined(lint)
|
||||||
static char rcsid[] = "$NetBSD: yp_all.c,v 1.1 1996/05/14 23:37:30 jtc Exp $";
|
static char rcsid[] = "$NetBSD: yp_all.c,v 1.2 1996/05/18 19:01:19 jtc Exp $";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <rpc/rpc.h>
|
#include <rpc/rpc.h>
|
||||||
#include <rpcsvc/yp_prot.h>
|
#include <rpcsvc/yp_prot.h>
|
||||||
#include <rpcsvc/ypclnt.h>
|
#include <rpcsvc/ypclnt.h>
|
||||||
|
|
||||||
extern int _yplib_timeout;
|
extern struct timeval _yplib_timeout;
|
||||||
extern int (*ypresp_allfn) __P((u_long, char *, int, char *, int, void *));
|
extern int (*ypresp_allfn) __P((u_long, char *, int, char *, int, void *));
|
||||||
extern void *ypresp_data;
|
extern void *ypresp_data;
|
||||||
|
|
||||||
@ -51,17 +51,23 @@ yp_all(indomain, inmap, incallback)
|
|||||||
{
|
{
|
||||||
struct ypreq_nokey yprnk;
|
struct ypreq_nokey yprnk;
|
||||||
struct dom_binding *ysd;
|
struct dom_binding *ysd;
|
||||||
struct timeval tv;
|
|
||||||
struct sockaddr_in clnt_sin;
|
struct sockaddr_in clnt_sin;
|
||||||
CLIENT *clnt;
|
CLIENT *clnt;
|
||||||
u_long status;
|
u_long status;
|
||||||
int clnt_sock;
|
int clnt_sock;
|
||||||
|
|
||||||
|
if (indomain == NULL || *indomain == '\0'
|
||||||
|
|| strlen(indomain) > YPMAXDOMAIN)
|
||||||
|
return YPERR_BADARGS;
|
||||||
|
if (inmap == NULL || *inmap == '\0'
|
||||||
|
|| strlen(inmap) > YPMAXMAP)
|
||||||
|
return YPERR_BADARGS;
|
||||||
|
if (incallback == NULL)
|
||||||
|
return YPERR_BADARGS;
|
||||||
|
|
||||||
if (_yp_dobind(indomain, &ysd) != 0)
|
if (_yp_dobind(indomain, &ysd) != 0)
|
||||||
return YPERR_DOMAIN;
|
return YPERR_DOMAIN;
|
||||||
|
|
||||||
tv.tv_sec = _yplib_timeout;
|
|
||||||
tv.tv_usec = 0;
|
|
||||||
clnt_sock = RPC_ANYSOCK;
|
clnt_sock = RPC_ANYSOCK;
|
||||||
clnt_sin = ysd->dom_server_addr;
|
clnt_sin = ysd->dom_server_addr;
|
||||||
clnt_sin.sin_port = 0;
|
clnt_sin.sin_port = 0;
|
||||||
@ -76,7 +82,8 @@ yp_all(indomain, inmap, incallback)
|
|||||||
ypresp_data = (void *) incallback->data;
|
ypresp_data = (void *) incallback->data;
|
||||||
|
|
||||||
(void) clnt_call(clnt, YPPROC_ALL,
|
(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,
|
||||||
|
_yplib_timeout);
|
||||||
clnt_destroy(clnt);
|
clnt_destroy(clnt);
|
||||||
/* not really needed... */
|
/* not really needed... */
|
||||||
xdr_free(xdr_ypresp_all_seq, (char *) &status);
|
xdr_free(xdr_ypresp_all_seq, (char *) &status);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: yp_master.c,v 1.1 1996/05/14 23:37:31 jtc Exp $ */
|
/* $NetBSD: yp_master.c,v 1.2 1996/05/18 19:01:24 jtc Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1992, 1993 Theo de Raadt <deraadt@fsa.ca>
|
* Copyright (c) 1992, 1993 Theo de Raadt <deraadt@fsa.ca>
|
||||||
@ -32,7 +32,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#if defined(LIBC_SCCS) && !defined(lint)
|
#if defined(LIBC_SCCS) && !defined(lint)
|
||||||
static char rcsid[] = "$NetBSD: yp_master.c,v 1.1 1996/05/14 23:37:31 jtc Exp $";
|
static char rcsid[] = "$NetBSD: yp_master.c,v 1.2 1996/05/18 19:01:24 jtc Exp $";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@ -40,7 +40,7 @@ static char rcsid[] = "$NetBSD: yp_master.c,v 1.1 1996/05/14 23:37:31 jtc Exp $"
|
|||||||
#include <rpcsvc/yp_prot.h>
|
#include <rpcsvc/yp_prot.h>
|
||||||
#include <rpcsvc/ypclnt.h>
|
#include <rpcsvc/ypclnt.h>
|
||||||
|
|
||||||
extern int _yplib_timeout;
|
extern struct timeval _yplib_timeout;
|
||||||
|
|
||||||
int
|
int
|
||||||
yp_master(indomain, inmap, outname)
|
yp_master(indomain, inmap, outname)
|
||||||
@ -51,23 +51,29 @@ yp_master(indomain, inmap, outname)
|
|||||||
struct dom_binding *ysd;
|
struct dom_binding *ysd;
|
||||||
struct ypresp_master yprm;
|
struct ypresp_master yprm;
|
||||||
struct ypreq_nokey yprnk;
|
struct ypreq_nokey yprnk;
|
||||||
struct timeval tv;
|
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
|
if (indomain == NULL || *indomain == '\0'
|
||||||
|
|| strlen(indomain) > YPMAXDOMAIN)
|
||||||
|
return YPERR_BADARGS;
|
||||||
|
if (inmap == NULL || *inmap == '\0'
|
||||||
|
|| strlen(inmap) > YPMAXMAP)
|
||||||
|
return YPERR_BADARGS;
|
||||||
|
if (outname == NULL)
|
||||||
|
return YPERR_BADARGS;
|
||||||
|
|
||||||
again:
|
again:
|
||||||
if (_yp_dobind(indomain, &ysd) != 0)
|
if (_yp_dobind(indomain, &ysd) != 0)
|
||||||
return YPERR_DOMAIN;
|
return YPERR_DOMAIN;
|
||||||
|
|
||||||
tv.tv_sec = _yplib_timeout;
|
|
||||||
tv.tv_usec = 0;
|
|
||||||
|
|
||||||
yprnk.domain = indomain;
|
yprnk.domain = indomain;
|
||||||
yprnk.map = inmap;
|
yprnk.map = inmap;
|
||||||
|
|
||||||
(void)memset(&yprm, 0, sizeof yprm);
|
(void)memset(&yprm, 0, sizeof yprm);
|
||||||
|
|
||||||
r = clnt_call(ysd->dom_client, YPPROC_MASTER,
|
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,
|
||||||
|
_yplib_timeout);
|
||||||
if (r != RPC_SUCCESS) {
|
if (r != RPC_SUCCESS) {
|
||||||
clnt_perror(ysd->dom_client, "yp_master: clnt_call");
|
clnt_perror(ysd->dom_client, "yp_master: clnt_call");
|
||||||
ysd->dom_vers = -1;
|
ysd->dom_vers = -1;
|
||||||
@ -75,7 +81,7 @@ again:
|
|||||||
}
|
}
|
||||||
if (!(r = ypprot_err(yprm.status))) {
|
if (!(r = ypprot_err(yprm.status))) {
|
||||||
if ((*outname = strdup(yprm.master)) == NULL)
|
if ((*outname = strdup(yprm.master)) == NULL)
|
||||||
r = RPC_SYSTEMERROR;
|
r = YPERR_RESRC;
|
||||||
}
|
}
|
||||||
xdr_free(xdr_ypresp_master, (char *) &yprm);
|
xdr_free(xdr_ypresp_master, (char *) &yprm);
|
||||||
_yp_unbind(ysd);
|
_yp_unbind(ysd);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: yp_match.c,v 1.1 1996/05/15 05:27:52 jtc Exp $ */
|
/* $NetBSD: yp_match.c,v 1.2 1996/05/18 19:01:27 jtc Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1992, 1993 Theo de Raadt <deraadt@fsa.ca>
|
* Copyright (c) 1992, 1993 Theo de Raadt <deraadt@fsa.ca>
|
||||||
@ -32,7 +32,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#if defined(LIBC_SCCS) && !defined(lint)
|
#if defined(LIBC_SCCS) && !defined(lint)
|
||||||
static char rcsid[] = "$NetBSD: yp_match.c,v 1.1 1996/05/15 05:27:52 jtc Exp $";
|
static char rcsid[] = "$NetBSD: yp_match.c,v 1.2 1996/05/18 19:01:27 jtc Exp $";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -43,8 +43,8 @@ static char rcsid[] = "$NetBSD: yp_match.c,v 1.1 1996/05/15 05:27:52 jtc Exp $";
|
|||||||
|
|
||||||
#define YPMATCHCACHE
|
#define YPMATCHCACHE
|
||||||
|
|
||||||
|
extern struct timeval _yplib_timeout;
|
||||||
extern char _yp_domain[];
|
extern char _yp_domain[];
|
||||||
extern int _yplib_timeout;
|
|
||||||
|
|
||||||
#ifdef YPMATCHCACHE
|
#ifdef YPMATCHCACHE
|
||||||
int _yplib_cache = 5;
|
int _yplib_cache = 5;
|
||||||
@ -166,10 +166,19 @@ yp_match(indomain, inmap, inkey, inkeylen, outval, outvallen)
|
|||||||
{
|
{
|
||||||
struct dom_binding *ysd;
|
struct dom_binding *ysd;
|
||||||
struct ypresp_val yprv;
|
struct ypresp_val yprv;
|
||||||
struct timeval tv;
|
|
||||||
struct ypreq_key yprk;
|
struct ypreq_key yprk;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
|
|
||||||
|
if (indomain == NULL || *indomain == '\0'
|
||||||
|
|| strlen(indomain) > YPMAXDOMAIN)
|
||||||
|
return YPERR_BADARGS;
|
||||||
|
if (inmap == NULL || *inmap == '\0'
|
||||||
|
|| strlen(inmap) > YPMAXMAP)
|
||||||
|
return YPERR_BADARGS;
|
||||||
|
if (inkey == NULL || inkeylen == 0)
|
||||||
|
return YPERR_BADARGS;
|
||||||
|
|
||||||
*outval = NULL;
|
*outval = NULL;
|
||||||
*outvallen = 0;
|
*outvallen = 0;
|
||||||
|
|
||||||
@ -189,9 +198,6 @@ again:
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
tv.tv_sec = _yplib_timeout;
|
|
||||||
tv.tv_usec = 0;
|
|
||||||
|
|
||||||
yprk.domain = indomain;
|
yprk.domain = indomain;
|
||||||
yprk.map = inmap;
|
yprk.map = inmap;
|
||||||
yprk.keydat.dptr = (char *) inkey;
|
yprk.keydat.dptr = (char *) inkey;
|
||||||
@ -200,7 +206,8 @@ again:
|
|||||||
memset(&yprv, 0, sizeof yprv);
|
memset(&yprv, 0, sizeof yprv);
|
||||||
|
|
||||||
r = clnt_call(ysd->dom_client, YPPROC_MATCH,
|
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,
|
||||||
|
_yplib_timeout);
|
||||||
if (r != RPC_SUCCESS) {
|
if (r != RPC_SUCCESS) {
|
||||||
clnt_perror(ysd->dom_client, "yp_match: clnt_call");
|
clnt_perror(ysd->dom_client, "yp_match: clnt_call");
|
||||||
ysd->dom_vers = -1;
|
ysd->dom_vers = -1;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: yp_order.c,v 1.1 1996/05/14 23:37:32 jtc Exp $ */
|
/* $NetBSD: yp_order.c,v 1.2 1996/05/18 19:01:31 jtc Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1992, 1993 Theo de Raadt <deraadt@fsa.ca>
|
* Copyright (c) 1992, 1993 Theo de Raadt <deraadt@fsa.ca>
|
||||||
@ -32,14 +32,14 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#if defined(LIBC_SCCS) && !defined(lint)
|
#if defined(LIBC_SCCS) && !defined(lint)
|
||||||
static char rcsid[] = "$NetBSD: yp_order.c,v 1.1 1996/05/14 23:37:32 jtc Exp $";
|
static char rcsid[] = "$NetBSD: yp_order.c,v 1.2 1996/05/18 19:01:31 jtc Exp $";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <rpc/rpc.h>
|
#include <rpc/rpc.h>
|
||||||
#include <rpcsvc/yp_prot.h>
|
#include <rpcsvc/yp_prot.h>
|
||||||
#include <rpcsvc/ypclnt.h>
|
#include <rpcsvc/ypclnt.h>
|
||||||
|
|
||||||
extern int _yplib_timeout;
|
extern struct timeval _yplib_timeout;
|
||||||
|
|
||||||
int
|
int
|
||||||
yp_order(indomain, inmap, outorder)
|
yp_order(indomain, inmap, outorder)
|
||||||
@ -50,23 +50,29 @@ yp_order(indomain, inmap, outorder)
|
|||||||
struct dom_binding *ysd;
|
struct dom_binding *ysd;
|
||||||
struct ypresp_order ypro;
|
struct ypresp_order ypro;
|
||||||
struct ypreq_nokey yprnk;
|
struct ypreq_nokey yprnk;
|
||||||
struct timeval tv;
|
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
|
if (indomain == NULL || *indomain == '\0'
|
||||||
|
|| strlen(indomain) > YPMAXDOMAIN)
|
||||||
|
return YPERR_BADARGS;
|
||||||
|
if (inmap == NULL || *inmap == '\0'
|
||||||
|
|| strlen(inmap) > YPMAXMAP)
|
||||||
|
return YPERR_BADARGS;
|
||||||
|
if (outorder == NULL)
|
||||||
|
return YPERR_BADARGS;
|
||||||
|
|
||||||
again:
|
again:
|
||||||
if (_yp_dobind(indomain, &ysd) != 0)
|
if (_yp_dobind(indomain, &ysd) != 0)
|
||||||
return YPERR_DOMAIN;
|
return YPERR_DOMAIN;
|
||||||
|
|
||||||
tv.tv_sec = _yplib_timeout;
|
|
||||||
tv.tv_usec = 0;
|
|
||||||
|
|
||||||
yprnk.domain = indomain;
|
yprnk.domain = indomain;
|
||||||
yprnk.map = inmap;
|
yprnk.map = inmap;
|
||||||
|
|
||||||
(void)memset(&ypro, 0, sizeof ypro);
|
(void)memset(&ypro, 0, sizeof ypro);
|
||||||
|
|
||||||
r = clnt_call(ysd->dom_client, YPPROC_ORDER,
|
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,
|
||||||
|
_yplib_timeout);
|
||||||
if (r != RPC_SUCCESS) {
|
if (r != RPC_SUCCESS) {
|
||||||
clnt_perror(ysd->dom_client, "yp_order: clnt_call");
|
clnt_perror(ysd->dom_client, "yp_order: clnt_call");
|
||||||
if (r == RPC_PROCUNAVAIL) {
|
if (r == RPC_PROCUNAVAIL) {
|
||||||
|
Loading…
Reference in New Issue
Block a user