sprinkle _DIAGASSERT() appropriately. minor other cleanups

This commit is contained in:
lukem 2001-01-04 14:42:18 +00:00
parent 4519a2cf89
commit 0e8cfd8ffb
18 changed files with 311 additions and 63 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: clnt_bcast.c,v 1.3 2000/07/06 03:05:20 christos Exp $ */
/* $NetBSD: clnt_bcast.c,v 1.4 2001/01/04 14:42:18 lukem Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
@ -70,6 +70,7 @@ static char sccsid[] = "@(#)clnt_bcast.c 1.15 89/04/21 Copyr 1988 Sun Micro";
#ifdef RPC_DEBUG
#include <stdio.h>
#endif
#include <assert.h>
#include <errno.h>
#include <stdlib.h>
#include <unistd.h>
@ -137,6 +138,8 @@ __rpc_getbroadifs(int af, int proto, int socktype, broadlist_t *list)
struct sockaddr_in *sin;
struct addrinfo hints, *res;
_DIAGASSERT(list != NULL);
if (getifaddrs(&ifp) < 0)
return 0;
@ -162,19 +165,20 @@ __rpc_getbroadifs(int af, int proto, int socktype, broadlist_t *list)
if (bip == NULL)
break;
bip->index = if_nametoindex(ifap->ifa_name);
if (
#ifdef INET6
if (af != AF_INET6 && (ifap->ifa_flags & IFF_BROADCAST)) {
#else
if (ifap->ifa_flags & IFF_BROADCAST) {
af != AF_INET6 &&
#endif
(ifap->ifa_flags & IFF_BROADCAST)) {
memcpy(&bip->broadaddr, ifap->ifa_broadaddr,
(size_t)ifap->ifa_broadaddr->sa_len);
sin = (struct sockaddr_in *)(void *)&bip->broadaddr;
sin->sin_port =
((struct sockaddr_in *)
(void *)res->ai_addr)->sin_port;
}
#ifdef INET6
} else if (af == AF_INET6) {
else if (af == AF_INET6) {
sin6 = (struct sockaddr_in6 *)(void *)&bip->broadaddr;
inet_pton(af, RPCB_MULTICAST_ADDR, &sin6->sin6_addr);
sin6->sin6_family = af;
@ -183,8 +187,8 @@ __rpc_getbroadifs(int af, int proto, int socktype, broadlist_t *list)
((struct sockaddr_in6 *)
(void *)res->ai_addr)->sin6_port;
sin6->sin6_scope_id = bip->index;
#endif
}
#endif
TAILQ_INSERT_TAIL(list, bip, link);
count++;
}
@ -199,6 +203,8 @@ __rpc_freebroadifs(broadlist_t *list)
{
struct broadif *bip, *next;
_DIAGASSERT(list != NULL);
bip = TAILQ_FIRST(list);
while (bip != NULL) {
@ -215,6 +221,8 @@ __rpc_broadenable(int af, int s, struct broadif *bip)
int o = 1;
#if 0
_DIAGASSERT(bip != NULL);
if (af == AF_INET6) {
fprintf(stderr, "set v6 multicast if to %d\n", bip->index);
if (setsockopt(s, IPPROTO_IPV6, IPV6_MULTICAST_IF, &bip->index,

View File

@ -1,4 +1,4 @@
/* $NetBSD: clnt_dg.c,v 1.6 2000/12/20 23:08:51 christos Exp $ */
/* $NetBSD: clnt_dg.c,v 1.7 2001/01/04 14:42:18 lukem Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
@ -52,6 +52,7 @@ static char sccsid[] = "@(#)clnt_dg.c 1.19 89/03/16 Copyr 1988 Sun Micro";
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <rpc/rpc.h>
#include <assert.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
@ -306,7 +307,7 @@ clnt_dg_call(cl, proc, xargs, argsp, xresults, resultsp, utimeout)
caddr_t resultsp; /* pointer to results */
struct timeval utimeout; /* seconds to wait before giving up */
{
struct cu_data *cu = (struct cu_data *)cl->cl_private;
struct cu_data *cu;
XDR *xdrs;
size_t outlen;
struct rpc_msg reply_msg;
@ -326,6 +327,10 @@ clnt_dg_call(cl, proc, xargs, argsp, xresults, resultsp, utimeout)
socklen_t fromlen, inlen;
ssize_t recvlen = 0;
_DIAGASSERT(cl != NULL);
cu = (struct cu_data *)cl->cl_private;
sigfillset(&newmask);
thr_sigsetmask(SIG_SETMASK, &newmask, &mask);
mutex_lock(&clnt_fd_lock);
@ -563,8 +568,12 @@ clnt_dg_geterr(cl, errp)
CLIENT *cl;
struct rpc_err *errp;
{
struct cu_data *cu = (struct cu_data *)cl->cl_private;
struct cu_data *cu;
_DIAGASSERT(cl != NULL);
_DIAGASSERT(errp != NULL);
cu = (struct cu_data *)cl->cl_private;
*errp = cu->cu_error;
}
@ -574,14 +583,18 @@ clnt_dg_freeres(cl, xdr_res, res_ptr)
xdrproc_t xdr_res;
caddr_t res_ptr;
{
struct cu_data *cu = (struct cu_data *)cl->cl_private;
XDR *xdrs = &(cu->cu_outxdrs);
struct cu_data *cu;
XDR *xdrs;
bool_t dummy;
#ifdef __REENT
sigset_t mask;
#endif
sigset_t newmask;
_DIAGASSERT(cl != NULL);
cu = (struct cu_data *)cl->cl_private;
xdrs = &(cu->cu_outxdrs);
sigfillset(&newmask);
thr_sigsetmask(SIG_SETMASK, &newmask, &mask);
mutex_lock(&clnt_fd_lock);
@ -608,13 +621,18 @@ clnt_dg_control(cl, request, info)
u_int request;
char *info;
{
struct cu_data *cu = (struct cu_data *)cl->cl_private;
struct cu_data *cu;
struct netbuf *addr;
#ifdef __REENT
sigset_t mask;
#endif
sigset_t newmask;
_DIAGASSERT(cl != NULL);
/* info is handled below */
cu = (struct cu_data *)cl->cl_private;
sigfillset(&newmask);
thr_sigsetmask(SIG_SETMASK, &newmask, &mask);
mutex_lock(&clnt_fd_lock);
@ -742,13 +760,18 @@ static void
clnt_dg_destroy(cl)
CLIENT *cl;
{
struct cu_data *cu = (struct cu_data *)cl->cl_private;
int cu_fd = cu->cu_fd;
struct cu_data *cu;
int cu_fd;
#ifdef __REENT
sigset_t mask;
#endif
sigset_t newmask;
_DIAGASSERT(cl != NULL);
cu = (struct cu_data *)cl->cl_private;
cu_fd = cu->cu_fd;
sigfillset(&newmask);
thr_sigsetmask(SIG_SETMASK, &newmask, &mask);
mutex_lock(&clnt_fd_lock);
@ -803,6 +826,9 @@ static bool_t
time_not_ok(t)
struct timeval *t;
{
_DIAGASSERT(t != NULL);
return (t->tv_sec < -1 || t->tv_sec > 100000000 ||
t->tv_usec < -1 || t->tv_usec > 1000000);
}
@ -817,6 +843,8 @@ __rpc_timeval_to_msec(t)
{
int t1, tmp;
_DIAGASSERT(t != NULL);
/*
* We're really returning t->tv_sec * 1000 + (t->tv_usec / 1000)
* but try to do so efficiently. Note: 1000 = 1024 - 16 - 8.

View File

@ -1,4 +1,4 @@
/* $NetBSD: clnt_generic.c,v 1.18 2000/07/06 03:10:34 christos Exp $ */
/* $NetBSD: clnt_generic.c,v 1.19 2001/01/04 14:42:18 lukem Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
@ -46,6 +46,7 @@ static char sccsid[] = "@(#)clnt_generic.c 1.32 89/03/16 Copyr 1988 Sun Micro";
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <assert.h>
#include <stdio.h>
#include <errno.h>
#include <rpc/rpc.h>
@ -82,6 +83,10 @@ clnt_create_vers(hostname, prog, vers_out, vers_low, vers_high, nettype)
enum clnt_stat rpc_stat;
struct rpc_err rpcerr;
_DIAGASSERT(hostname != NULL);
_DIAGASSERT(vers_out != NULL);
/* XXX: nettype appears to support being NULL */
clnt = clnt_create(hostname, prog, vers_high, nettype);
if (clnt == NULL) {
return (NULL);
@ -151,6 +156,8 @@ clnt_create(hostname, prog, vers, nettype)
enum clnt_stat save_cf_stat = RPC_SUCCESS;
struct rpc_err save_cf_error;
_DIAGASSERT(hostname != NULL);
/* XXX: nettype appears to support being NULL */
if ((handle = __rpc_setconf(nettype)) == NULL) {
rpc_createerr.cf_stat = RPC_UNKNOWNPROTO;
@ -219,6 +226,9 @@ clnt_tp_create(hostname, prog, vers, nconf)
struct netbuf *svcaddr; /* servers address */
CLIENT *cl = NULL; /* client handle */
_DIAGASSERT(hostname != NULL);
/* nconf is handled below */
if (nconf == NULL) {
rpc_createerr.cf_stat = RPC_UNKNOWNPROTO;
return (NULL);
@ -279,6 +289,9 @@ clnt_tli_create(fd, nconf, svcaddr, prog, vers, sendsz, recvsz)
int one = 1;
struct __rpc_sockinfo si;
/* nconf is handled below */
_DIAGASSERT(svcaddr != NULL);
if (fd == RPC_ANYFD) {
if (nconf == NULL) {
rpc_createerr.cf_stat = RPC_UNKNOWNPROTO;

View File

@ -1,4 +1,4 @@
/* $NetBSD: clnt_simple.c,v 1.21 2000/07/06 03:10:34 christos Exp $ */
/* $NetBSD: clnt_simple.c,v 1.22 2001/01/04 14:42:19 lukem Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
@ -50,6 +50,7 @@ static char sccsid[] = "@(#)clnt_simple.c 1.49 89/01/31 Copyr 1984 Sun Micro";
#include "reentrant.h"
#include <sys/param.h>
#include <stdio.h>
#include <assert.h>
#include <errno.h>
#include <rpc/rpc.h>
#include <string.h>
@ -123,6 +124,11 @@ rpc_call(host, prognum, versnum, procnum, inproc, in, outproc, out, nettype)
#endif
int main_thread = 1;
_DIAGASSERT(host != NULL);
/* XXX: in may be NULL ??? */
/* XXX: out may be NULL ??? */
/* XXX: nettype may be NULL ??? */
#ifdef __REENT
if ((main_thread = _thr_main())) {
rcp = rpc_call_private_main;

View File

@ -1,4 +1,4 @@
/* $NetBSD: clnt_vc.c,v 1.6 2000/12/20 23:08:51 christos Exp $ */
/* $NetBSD: clnt_vc.c,v 1.7 2001/01/04 14:42:19 lukem Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
@ -36,7 +36,7 @@ static char *sccsid = "@(#)clnt_tcp.c 1.37 87/10/05 Copyr 1984 Sun Micro";
static char *sccsid = "@(#)clnt_tcp.c 2.2 88/08/01 4.0 RPCSRC";
static char sccsid[] = "@(#)clnt_vc.c 1.19 89/03/16 Copyr 1988 Sun Micro";
#else
__RCSID("$NetBSD: clnt_vc.c,v 1.6 2000/12/20 23:08:51 christos Exp $");
__RCSID("$NetBSD: clnt_vc.c,v 1.7 2001/01/04 14:42:19 lukem Exp $");
#endif
#endif
@ -175,6 +175,8 @@ clnt_vc_create(fd, raddr, prog, vers, sendsz, recvsz)
socklen_t slen;
struct __rpc_sockinfo si;
_DIAGASSERT(raddr != NULL);
if (disrupt == 0)
disrupt = (u_int32_t)(long)raddr;
@ -774,6 +776,9 @@ static bool_t
time_not_ok(t)
struct timeval *t;
{
_DIAGASSERT(t != NULL);
return (t->tv_sec <= -1 || t->tv_sec > 100000000 ||
t->tv_usec <= -1 || t->tv_usec > 1000000);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: getnetconfig.c,v 1.3 2000/07/06 03:10:34 christos Exp $ */
/* $NetBSD: getnetconfig.c,v 1.4 2001/01/04 14:42:19 lukem Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
@ -42,6 +42,7 @@ static char sccsid[] = "@(#)getnetconfig.c 1.12 91/12/19 SMI";
#include "namespace.h"
#include <sys/cdefs.h>
#include <stdio.h>
#include <assert.h>
#include <errno.h>
#include <netconfig.h>
#include <stdlib.h>
@ -522,6 +523,9 @@ struct netconfig *ncp; /* where to put results */
char *tokenp; /* for processing tokens */
char *lasts;
_DIAGASSERT(stringp != NULL);
_DIAGASSERT(ncp != NULL);
nc_error = NC_BADFILE; /* nearly anything that breaks is for this reason */
stringp[strlen(stringp)-1] = '\0'; /* get rid of newline */
/* netid */
@ -634,6 +638,9 @@ void
nc_perror(s)
const char *s;
{
_DIAGASSERT(s != NULL);
fprintf(stderr, "%s: %s", s, nc_sperror());
}
@ -648,6 +655,8 @@ struct netconfig *ncp;
char *tmp;
int i;
_DIAGASSERT(ncp != NULL);
if ((tmp=malloc(MAXNETCONFIGLINE)) == NULL)
return(NULL);
if ((p=(struct netconfig *)malloc(sizeof(struct netconfig))) == NULL) {

View File

@ -1,4 +1,4 @@
/* $NetBSD: getnetpath.c,v 1.3 2000/07/06 03:10:34 christos Exp $ */
/* $NetBSD: getnetpath.c,v 1.4 2001/01/04 14:42:19 lukem Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
@ -42,6 +42,7 @@ static char sccsid[] = "@(#)getnetpath.c 1.11 91/12/19 SMI";
#include "namespace.h"
#include <sys/cdefs.h>
#include <stdio.h>
#include <assert.h>
#include <errno.h>
#include <netconfig.h>
#include <stdlib.h>
@ -90,7 +91,6 @@ char *_get_next_token __P((char *, int));
void *
setnetpath()
{
struct netpath_vars *np_sessionp; /* this session's variables */
char *npp; /* NETPATH env variable */
@ -245,6 +245,9 @@ int token; /* char to parse string for */
char *np; /* netpath pointer */
char *ep; /* escape pointer */
_DIAGASSERT(npp != NULL);
_DIAGASSERT(token != NULL);
if ((cp = strchr(npp, token)) == NULL) {
return (NULL);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: pmap_prot2.c,v 1.14 2000/07/06 03:10:34 christos Exp $ */
/* $NetBSD: pmap_prot2.c,v 1.15 2001/01/04 14:42:20 lukem Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
@ -35,7 +35,7 @@
static char *sccsid = "@(#)pmap_prot2.c 1.3 87/08/11 Copyr 1984 Sun Micro";
static char *sccsid = "@(#)pmap_prot2.c 2.1 88/07/29 4.0 RPCSRC";
#else
__RCSID("$NetBSD: pmap_prot2.c,v 1.14 2000/07/06 03:10:34 christos Exp $");
__RCSID("$NetBSD: pmap_prot2.c,v 1.15 2001/01/04 14:42:20 lukem Exp $");
#endif
#endif
@ -145,5 +145,9 @@ xdr_pmaplist_ptr(xdrs, rp)
XDR *xdrs;
struct pmaplist *rp;
{
_DIAGASSERT(xdrs != NULL);
_DIAGASSERT(rp != NULL);
return xdr_pmaplist(xdrs, (struct pmaplist **)(void *)rp);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: rpc_generic.c,v 1.4 2000/09/28 09:07:04 kleink Exp $ */
/* $NetBSD: rpc_generic.c,v 1.5 2001/01/04 14:42:20 lukem Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
@ -48,6 +48,7 @@
#include <netinet/in.h>
#include <arpa/inet.h>
#include <rpc/rpc.h>
#include <assert.h>
#include <ctype.h>
#include <stdio.h>
#include <netdb.h>
@ -182,6 +183,8 @@ strlocase(p)
{
char *t = p;
_DIAGASSERT(p != NULL);
for (; *p; p++)
if (isupper(*p))
*p = tolower(*p);
@ -255,6 +258,9 @@ __rpc_getconfip(nettype)
netid_udp = netid_udp_main;
netid_tcp = netid_tcp_main;
#endif
_DIAGASSERT(nettype != NULL);
if (!netid_udp && !netid_tcp) {
struct netconfig *nconf;
void *confighandle;
@ -317,6 +323,8 @@ __rpc_setconf(nettype)
{
struct handle *handle;
/* nettype may be NULL; getnettype() supports that */
handle = (struct handle *) malloc(sizeof (struct handle));
if (handle == NULL) {
return (NULL);
@ -494,6 +502,8 @@ __rpc_fd2sockinfo(int fd, struct __rpc_sockinfo *sip)
int type, proto;
struct sockaddr_storage ss;
_DIAGASSERT(sip != NULL);
len = sizeof ss;
if (getsockname(fd, (struct sockaddr *)(void *)&ss, &len) < 0)
return 0;
@ -529,6 +539,9 @@ __rpc_nconf2sockinfo(const struct netconfig *nconf, struct __rpc_sockinfo *sip)
{
int i;
_DIAGASSERT(nconf != NULL);
_DIAGASSERT(sip != NULL);
for (i = 0; i < (sizeof na_cvt) / (sizeof (struct netid_af)); i++)
if (!strcmp(na_cvt[i].netid, nconf->nc_netid)) {
sip->si_af = na_cvt[i].af;
@ -549,6 +562,8 @@ __rpc_nconf2fd(const struct netconfig *nconf)
{
struct __rpc_sockinfo si;
_DIAGASSERT(nconf != NULL);
if (!__rpc_nconf2sockinfo(nconf, &si))
return 0;
@ -560,6 +575,9 @@ __rpc_sockinfo2netid(struct __rpc_sockinfo *sip, const char **netid)
{
int i;
_DIAGASSERT(sip != NULL);
/* netid may be NULL */
for (i = 0; i < (sizeof na_cvt) / (sizeof (struct netid_af)); i++)
if (na_cvt[i].af == sip->si_af &&
na_cvt[i].protocol == sip->si_proto) {
@ -576,6 +594,9 @@ taddr2uaddr(const struct netconfig *nconf, const struct netbuf *nbuf)
{
struct __rpc_sockinfo si;
_DIAGASSERT(nconf != NULL);
_DIAGASSERT(nbuf != NULL);
if (!__rpc_nconf2sockinfo(nconf, &si))
return NULL;
return __rpc_taddr2uaddr_af(si.si_af, nbuf);
@ -585,6 +606,9 @@ struct netbuf *
uaddr2taddr(const struct netconfig *nconf, const char *uaddr)
{
struct __rpc_sockinfo si;
_DIAGASSERT(nconf != NULL);
_DIAGASSERT(uaddr != NULL);
if (!__rpc_nconf2sockinfo(nconf, &si))
return NULL;
@ -604,6 +628,8 @@ __rpc_taddr2uaddr_af(int af, const struct netbuf *nbuf)
#endif
u_int16_t port;
_DIAGASSERT(nbuf != NULL);
switch (af) {
case AF_INET:
sin = nbuf->buf;
@ -651,6 +677,8 @@ __rpc_uaddr2taddr_af(int af, const char *uaddr)
#endif
struct sockaddr_un *sun;
_DIAGASSERT(uaddr != NULL);
addrstr = strdup(uaddr);
if (addrstr == NULL)
return NULL;
@ -775,6 +803,9 @@ __rpc_fixup_addr(struct netbuf *new, const struct netbuf *svc)
struct sockaddr *sa_new, *sa_svc;
struct sockaddr_in6 *sin6_new, *sin6_svc;
_DIAGASSERT(new != NULL);
_DIAGASSERT(svc != NULL);
sa_svc = (struct sockaddr *)svc->buf;
sa_new = (struct sockaddr *)new->buf;

View File

@ -1,4 +1,4 @@
/* $NetBSD: rpc_soc.c,v 1.6 2000/07/06 03:10:35 christos Exp $ */
/* $NetBSD: rpc_soc.c,v 1.7 2001/01/04 14:42:20 lukem Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
@ -64,11 +64,12 @@ static char sccsid[] = "@(#)rpc_soc.c 1.41 89/05/02 Copyr 1988 Sun Micro";
#include <rpc/pmap_prot.h>
#include <rpc/nettype.h>
#include <netinet/in.h>
#include <netdb.h>
#include <assert.h>
#include <errno.h>
#include <syslog.h>
#include <netdb.h>
#include <stdlib.h>
#include <string.h>
#include <syslog.h>
#include <unistd.h>
#include "rpc_com.h"
@ -113,10 +114,16 @@ clnt_com_create(raddr, prog, vers, sockp, sendsz, recvsz, tp)
{
CLIENT *cl;
int madefd = FALSE;
int fd = *sockp;
int fd;
struct netconfig *nconf;
struct netbuf bindaddr;
_DIAGASSERT(raddr != NULL);
_DIAGASSERT(sockp != NULL);
_DIAGASSERT(tp != NULL);
fd = *sockp;
mutex_lock(&rpcsoc_lock);
if ((nconf = __rpc_getconfip(tp)) == NULL) {
rpc_createerr.cf_stat = RPC_UNKNOWNPROTO;
@ -189,6 +196,9 @@ clntudp_bufcreate(raddr, prog, vers, wait, sockp, sendsz, recvsz)
{
CLIENT *cl;
_DIAGASSERT(raddr != NULL);
_DIAGASSERT(sockp != NULL);
cl = clnt_com_create(raddr, (rpcprog_t)prog, (rpcvers_t)vers, sockp,
sendsz, recvsz, "udp");
if (cl == NULL) {
@ -247,6 +257,8 @@ svc_com_create(fd, sendsize, recvsize, netid)
int port;
struct sockaddr_in sin;
_DIAGASSERT(netid != NULL);
if ((nconf = __rpc_getconfip(netid)) == NULL) {
(void) syslog(LOG_ERR, "Could not get %s transport", netid);
return (NULL);
@ -322,6 +334,9 @@ int
get_myaddress(addr)
struct sockaddr_in *addr;
{
_DIAGASSERT(addr != NULL);
memset((void *) addr, 0, sizeof(*addr));
addr->sin_family = AF_INET;
addr->sin_port = htons(PMAPPORT);
@ -378,6 +393,10 @@ rpc_wrap_bcast(resultp, addr, nconf)
{
resultproc_t clnt_broadcast_result;
_DIAGASSERT(resultp != NULL);
_DIAGASSERT(addr != NULL);
_DIAGASSERT(nconf != NULL);
if (strcmp(nconf->nc_netid, "udp"))
return (FALSE);
#ifdef __REENT

View File

@ -1,4 +1,4 @@
/* $NetBSD: rpcb_clnt.c,v 1.7 2000/12/20 20:52:24 christos Exp $ */
/* $NetBSD: rpcb_clnt.c,v 1.8 2001/01/04 14:42:20 lukem Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
@ -62,13 +62,14 @@ static char sccsid[] = "@(#)rpcb_clnt.c 1.30 89/06/21 Copyr 1988 Sun Micro";
#include <netinet/in.h> /* FOR IPPROTO_TCP/UDP definitions */
#include <rpc/pmap_prot.h>
#endif
#include <stdio.h>
#include <assert.h>
#include <errno.h>
#include <netdb.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <netdb.h>
#include <syslog.h>
#include <unistd.h>
#include "rpc_com.h"
@ -127,6 +128,9 @@ __rpc_control(request, info)
int request;
void *info;
{
_DIAGASSERT(info != NULL);
switch (request) {
case CLCR_GET_RPCB_TIMEOUT:
*(struct timeval *)info = tottimeout;
@ -172,6 +176,9 @@ check_cache(host, netid)
{
struct address_cache *cptr;
_DIAGASSERT(host != NULL);
_DIAGASSERT(netid != NULL);
/* READ LOCK HELD ON ENTRY: rpcbaddr_cache_lock */
for (cptr = front; cptr != NULL; cptr = cptr->ac_next) {
@ -193,6 +200,8 @@ delete_cache(addr)
{
struct address_cache *cptr, *prevptr = NULL;
_DIAGASSERT(addr != NULL);
/* WRITE LOCK HELD ON ENTRY: rpcbaddr_cache_lock */
for (cptr = front; cptr != NULL; cptr = cptr->ac_next) {
if (!memcmp(cptr->ac_taddr->buf, addr->buf, addr->len)) {
@ -222,6 +231,11 @@ add_cache(host, netid, taddr, uaddr)
{
struct address_cache *ad_cache, *cptr, *prevptr;
_DIAGASSERT(host != NULL);
_DIAGASSERT(netid != NULL);
/* uaddr may be NULL */
/* taddr may be NULL ??? */
ad_cache = (struct address_cache *)
malloc(sizeof (struct address_cache));
if (!ad_cache) {
@ -303,6 +317,10 @@ getclnthandle(host, nconf, targaddr)
struct address_cache *ad_cache;
char *tmpaddr;
_DIAGASSERT(host != NULL);
_DIAGASSERT(nconf != NULL);
/* targaddr may be NULL */
/* VARIABLES PROTECTED BY rpcbaddr_cache_lock: ad_cache */
/* Get the address of the rpcbind. Check cache first */
@ -616,6 +634,8 @@ got_entry(relp, nconf)
rpcb_entry_list_ptr sp;
rpcb_entry *rmap;
_DIAGASSERT(nconf != NULL);
for (sp = relp; sp != NULL; sp = sp->rpcb_entry_next) {
rmap = &sp->rpcb_entry_map;
if ((strcmp(nconf->nc_proto, rmap->r_nc_proto) == 0) &&
@ -671,6 +691,10 @@ __rpcb_findaddr(program, version, nconf, host, clpp)
rpcvers_t start_vers = RPCBVERS4;
struct netbuf servaddr;
/* nconf is handled below */
_DIAGASSERT(host != NULL);
/* clpp may be NULL */
/* parameter checking */
if (nconf == NULL) {
rpc_createerr.cf_stat = RPC_UNKNOWNPROTO;
@ -776,14 +800,15 @@ try_rpcbind:
#if 1
if ((nconf->nc_semantics == NC_TPI_COTS_ORD ||
nconf->nc_semantics == NC_TPI_COTS) &&
(strcmp(nconf->nc_protofmly, NC_LOOPBACK) != 0)) {
(strcmp(nconf->nc_protofmly, NC_LOOPBACK) != 0))
#else
if (client != NULL) {
CLNT_DESTROY(client);
client = NULL;
}
if (nconf->nc_semantics == NC_TPI_CLTS) {
if (nconf->nc_semantics == NC_TPI_CLTS)
#endif
{
void *handle;
struct netconfig *nconf_clts;
rpcb_entry_list_ptr relp = NULL;
@ -791,10 +816,11 @@ try_rpcbind:
if (client == NULL) {
/* This did not go through the above PORTMAP/TCP code */
#if 1
if ((handle = __rpc_setconf("datagram_v")) != NULL) {
if ((handle = __rpc_setconf("datagram_v")) != NULL)
#else
if ((handle = __rpc_setconf("circuit_v")) != NULL) {
if ((handle = __rpc_setconf("circuit_v")) != NULL)
#endif
{
while ((nconf_clts = __rpc_getconf(handle))
!= NULL) {
if (strcmp(nconf_clts->nc_protofmly,
@ -858,10 +884,11 @@ regular_rpcbind:
/* Now the same transport is to be used to get the address */
#if 1
if (client && ((nconf->nc_semantics == NC_TPI_COTS_ORD) ||
(nconf->nc_semantics == NC_TPI_COTS))) {
(nconf->nc_semantics == NC_TPI_COTS)))
#else
if (client && nconf->nc_semantics == NC_TPI_CLTS) {
if (client && nconf->nc_semantics == NC_TPI_CLTS)
#endif
{
/* A CLTS type of client - destroy it */
CLNT_DESTROY(client);
client = NULL;
@ -970,6 +997,8 @@ rpcb_getaddr(program, version, nconf, address, host)
{
struct netbuf *na;
_DIAGASSERT(address != NULL);
if ((na = __rpcb_findaddr(program, version, nconf,
host, (CLIENT **) NULL)) == NULL)
return (FALSE);
@ -1066,7 +1095,6 @@ rpcb_rmtcall(nconf, host, prog, vers, proc, xdrargs, argsp,
struct r_rpcb_rmtcallres r;
rpcvers_t rpcb_vers;
client = getclnthandle(host, nconf, NULL);
if (client == NULL) {
return (RPC_FAILED);

View File

@ -1,4 +1,4 @@
/* $NetBSD: rpcb_prot.c,v 1.3 2000/07/14 08:40:42 fvdl Exp $ */
/* $NetBSD: rpcb_prot.c,v 1.4 2001/01/04 14:42:21 lukem Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
@ -54,6 +54,8 @@ static char sccsid[] = "@(#)rpcb_prot.c 1.9 89/04/21 Copyr 1984 Sun Micro";
#include <rpc/xdr.h>
#include <rpc/rpcb_prot.h>
#include <assert.h>
#ifdef __weak_alias
__weak_alias(xdr_rpcb,_xdr_rpcb)
__weak_alias(xdr_rpcblist_ptr,_xdr_rpcblist_ptr)
@ -71,6 +73,9 @@ xdr_rpcb(xdrs, objp)
XDR *xdrs;
RPCB *objp;
{
_DIAGASSERT(objp != NULL);
if (!xdr_u_int32_t(xdrs, &objp->r_prog)) {
return (FALSE);
}
@ -123,10 +128,15 @@ xdr_rpcblist_ptr(xdrs, rp)
* xdr_bool when the direction is XDR_DECODE.
*/
bool_t more_elements;
int freeing = (xdrs->x_op == XDR_FREE);
int freeing;
rpcblist_ptr next;
rpcblist_ptr next_copy;
_DIAGASSERT(xdrs != NULL);
/* XXX: rp may be NULL ??? */
freeing = (xdrs->x_op == XDR_FREE);
for (;;) {
more_elements = (bool_t)(*rp != NULL);
if (! xdr_bool(xdrs, &more_elements)) {
@ -182,6 +192,9 @@ xdr_rpcb_entry(xdrs, objp)
XDR *xdrs;
rpcb_entry *objp;
{
_DIAGASSERT(objp != NULL);
if (!xdr_string(xdrs, &objp->r_maddr, (u_int)~0)) {
return (FALSE);
}
@ -211,10 +224,15 @@ xdr_rpcb_entry_list_ptr(xdrs, rp)
* xdr_bool when the direction is XDR_DECODE.
*/
bool_t more_elements;
int freeing = (xdrs->x_op == XDR_FREE);
int freeing;
rpcb_entry_list_ptr next;
rpcb_entry_list_ptr next_copy;
_DIAGASSERT(xdrs != NULL);
/* XXX: rp is allowed to be NULL ??? */
freeing = (xdrs->x_op == XDR_FREE);
for (;;) {
more_elements = (bool_t)(*rp != NULL);
if (! xdr_bool(xdrs, &more_elements)) {
@ -264,6 +282,8 @@ xdr_rpcb_rmtcallargs(xdrs, p)
u_int lenposition, argposition, position;
int32_t *buf;
_DIAGASSERT(p != NULL);
buf = XDR_INLINE(xdrs, 3 * BYTES_PER_XDR_UNIT);
if (buf == NULL) {
if (!xdr_u_int32_t(xdrs, &objp->prog)) {
@ -314,6 +334,8 @@ xdr_rpcb_rmtcallres(xdrs, p)
bool_t dummy;
struct r_rpcb_rmtcallres *objp = (struct r_rpcb_rmtcallres *)(void *)p;
_DIAGASSERT(p != NULL);
if (!xdr_string(xdrs, &objp->addr, (u_int)~0)) {
return (FALSE);
}
@ -331,6 +353,8 @@ xdr_netbuf(xdrs, objp)
{
bool_t dummy;
_DIAGASSERT(objp != NULL);
if (!xdr_u_int32_t(xdrs, (u_int32_t *) &objp->maxlen)) {
return (FALSE);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: rpcb_st_xdr.c,v 1.3 2000/07/14 08:40:42 fvdl Exp $ */
/* $NetBSD: rpcb_st_xdr.c,v 1.4 2001/01/04 14:42:21 lukem Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
@ -41,6 +41,8 @@
#include "namespace.h"
#include <rpc/rpc.h>
#include <assert.h>
/* Link list of all the stats about getport and getaddr */
#ifdef __weak_alias
@ -59,6 +61,8 @@ xdr_rpcbs_addrlist(xdrs, objp)
rpcbs_addrlist *objp;
{
_DIAGASSERT(objp != NULL);
if (!xdr_u_int32_t(xdrs, &objp->prog)) {
return (FALSE);
}
@ -93,6 +97,9 @@ xdr_rpcbs_rmtcalllist(xdrs, objp)
{
int32_t *buf;
_DIAGASSERT(xdrs != NULL);
_DIAGASSERT(objp != NULL);
if (xdrs->x_op == XDR_ENCODE) {
buf = XDR_INLINE(xdrs, 6 * BYTES_PER_XDR_UNIT);
if (buf == NULL) {
@ -241,6 +248,8 @@ xdr_rpcb_stat(xdrs, objp)
rpcb_stat *objp;
{
_DIAGASSERT(objp != NULL);
if (!xdr_rpcbs_proc(xdrs, objp->info)) {
return (FALSE);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: svc.c,v 1.21 2000/07/06 03:10:35 christos Exp $ */
/* $NetBSD: svc.c,v 1.22 2001/01/04 14:42:21 lukem Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
@ -35,7 +35,7 @@
static char *sccsid = "@(#)svc.c 1.44 88/02/08 Copyr 1984 Sun Micro";
static char *sccsid = "@(#)svc.c 2.4 88/08/11 4.0 RPCSRC";
#else
__RCSID("$NetBSD: svc.c,v 1.21 2000/07/06 03:10:35 christos Exp $");
__RCSID("$NetBSD: svc.c,v 1.22 2001/01/04 14:42:21 lukem Exp $");
#endif
#endif
@ -193,6 +193,9 @@ svc_reg(xprt, prog, vers, dispatch, nconf)
char *netid = NULL;
int flag = 0;
_DIAGASSERT(xprt != NULL);
/* XXX: dispatch may be NULL ??? */
/* VARIABLES PROTECTED BY svc_lock: s, prev, svc_head */
if (xprt->xp_netid) {
@ -362,6 +365,7 @@ svc_find(prog, vers, prev, netid)
struct svc_callout *s, *p;
_DIAGASSERT(prev != NULL);
/* netid is handled below */
p = NULL;
for (s = svc_head; s != NULL; s = s->sc_next) {
@ -466,6 +470,8 @@ __svc_versquiet_on(xprt)
{
u_long tmp;
_DIAGASSERT(xprt != NULL);
tmp = ((u_long) xprt->xp_p3) | SVC_VERSQUIET;
xprt->xp_p3 = (caddr_t) tmp;
}
@ -476,6 +482,8 @@ __svc_versquiet_off(xprt)
{
u_long tmp;
_DIAGASSERT(xprt != NULL);
tmp = ((u_long) xprt->xp_p3) & ~SVC_VERSQUIET;
xprt->xp_p3 = (caddr_t) tmp;
}
@ -491,6 +499,9 @@ int
__svc_versquiet_get(xprt)
SVCXPRT *xprt;
{
_DIAGASSERT(xprt != NULL);
return ((int) xprt->xp_p3) & SVC_VERSQUIET;
}
#endif
@ -713,6 +724,8 @@ svc_getreq_poll(pfdp, pollretval)
int i;
int fds_found;
_DIAGASSERT(pfdp != NULL);
for (i = fds_found = 0; fds_found < pollretval; i++) {
struct pollfd *p = &pfdp[i];

View File

@ -1,4 +1,4 @@
/* $NetBSD: svc_auth.c,v 1.12 2000/07/06 03:10:35 christos Exp $ */
/* $NetBSD: svc_auth.c,v 1.13 2001/01/04 14:42:21 lukem Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
@ -49,6 +49,7 @@ static char sccsid[] = "@(#)svc_auth.c 1.26 89/02/07 Copyr 1984 Sun Micro";
#include "reentrant.h"
#include <sys/types.h>
#include <rpc/rpc.h>
#include <assert.h>
#include <stdlib.h>
#ifdef __weak_alias
@ -108,6 +109,9 @@ _authenticate(rqst, msg)
extern mutex_t authsvc_lock;
#endif
_DIAGASSERT(rqst != NULL);
_DIAGASSERT(msg != NULL);
/* VARIABLES PROTECTED BY authsvc_lock: asp, Auths */
rqst->rq_cred = msg->rm_call.cb_cred;

View File

@ -1,4 +1,4 @@
/* $NetBSD: svc_dg.c,v 1.5 2000/12/20 20:52:24 christos Exp $ */
/* $NetBSD: svc_dg.c,v 1.6 2001/01/04 14:42:22 lukem Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
@ -47,6 +47,7 @@
#include <sys/types.h>
#include <sys/socket.h>
#include <rpc/rpc.h>
#include <assert.h>
#include <errno.h>
#include <unistd.h>
#include <stdio.h>
@ -176,14 +177,20 @@ svc_dg_recv(xprt, msg)
SVCXPRT *xprt;
struct rpc_msg *msg;
{
struct svc_dg_data *su = su_data(xprt);
XDR *xdrs = &(su->su_xdrs);
struct svc_dg_data *su;
XDR *xdrs;
char *reply;
struct sockaddr_storage ss;
socklen_t alen;
size_t replylen;
int rlen;
_DIAGASSERT(xprt != NULL);
_DIAGASSERT(msg != NULL);
su = su_data(xprt);
xdrs = &(su->su_xdrs);
again:
alen = sizeof (struct sockaddr_storage);
rlen = recvfrom(xprt->xp_fd, rpc_buffer(xprt), su->su_iosz, 0,
@ -226,11 +233,17 @@ svc_dg_reply(xprt, msg)
SVCXPRT *xprt;
struct rpc_msg *msg;
{
struct svc_dg_data *su = su_data(xprt);
XDR *xdrs = &(su->su_xdrs);
struct svc_dg_data *su;
XDR *xdrs;
bool_t stat = FALSE;
size_t slen;
_DIAGASSERT(xprt != NULL);
_DIAGASSERT(msg != NULL);
su = su_data(xprt);
xdrs = &(su->su_xdrs);
xdrs->x_op = XDR_ENCODE;
XDR_SETPOS(xdrs, 0);
msg->rm_xid = su->su_xid;
@ -262,8 +275,11 @@ svc_dg_freeargs(xprt, xdr_args, args_ptr)
xdrproc_t xdr_args;
caddr_t args_ptr;
{
XDR *xdrs = &(su_data(xprt)->su_xdrs);
XDR *xdrs;
_DIAGASSERT(xprt != NULL);
xdrs = &(su_data(xprt)->su_xdrs);
xdrs->x_op = XDR_FREE;
return (*xdr_args)(xdrs, args_ptr);
}
@ -272,7 +288,11 @@ static void
svc_dg_destroy(xprt)
SVCXPRT *xprt;
{
struct svc_dg_data *su = su_data(xprt);
struct svc_dg_data *su;
_DIAGASSERT(xprt != NULL);
su = su_data(xprt);
xprt_unregister(xprt);
if (xprt->xp_fd != -1)
@ -309,6 +329,8 @@ svc_dg_ops(xprt)
extern mutex_t ops_lock;
#endif
_DIAGASSERT(xprt != NULL);
/* VARIABLES PROTECTED BY ops_lock: ops */
mutex_lock(&ops_lock);
@ -410,9 +432,13 @@ svc_dg_enablecache(transp, size)
SVCXPRT *transp;
u_int size;
{
struct svc_dg_data *su = su_data(transp);
struct svc_dg_data *su;
struct cl_cache *uc;
_DIAGASSERT(transp != NULL);
su = su_data(transp);
mutex_lock(&dupreq_lock);
if (su->su_cache != NULL) {
(void) warnx(cache_enable_str, enable_err, " ");
@ -469,8 +495,8 @@ cache_set(xprt, replylen)
{
cache_ptr victim;
cache_ptr *vicp;
struct svc_dg_data *su = su_data(xprt);
struct cl_cache *uc = (struct cl_cache *) su->su_cache;
struct svc_dg_data *su;
struct cl_cache *uc;
u_int loc;
char *newbuf;
#ifdef RPC_CACHE_DEBUG
@ -478,6 +504,11 @@ cache_set(xprt, replylen)
char *uaddr;
#endif
_DIAGASSERT(xprt != NULL);
su = su_data(xprt);
uc = (struct cl_cache *) su->su_cache;
mutex_lock(&dupreq_lock);
/*
* Find space for the new entry, either by
@ -561,13 +592,21 @@ cache_get(xprt, msg, replyp, replylenp)
{
u_int loc;
cache_ptr ent;
struct svc_dg_data *su = su_data(xprt);
struct cl_cache *uc = (struct cl_cache *) su->su_cache;
struct svc_dg_data *su;
struct cl_cache *uc;
#ifdef RPC_CACHE_DEBUG
struct netconfig *nconf;
char *uaddr;
#endif
_DIAGASSERT(xprt != NULL);
_DIAGASSERT(msg != NULL);
_DIAGASSERT(replyp != NULL);
_DIAGASSERT(replylenp != NULL);
su = su_data(xprt);
uc = (struct cl_cache *) su->su_cache;
mutex_lock(&dupreq_lock);
loc = CACHE_LOC(xprt, su->su_xid);
for (ent = uc->uc_entries[loc]; ent != NULL; ent = ent->cache_next) {

View File

@ -1,4 +1,4 @@
/* $NetBSD: svc_raw.c,v 1.14 2000/07/06 03:10:35 christos Exp $ */
/* $NetBSD: svc_raw.c,v 1.15 2001/01/04 14:42:22 lukem Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
@ -53,6 +53,7 @@ static char sccsid[] = "@(#)svc_raw.c 1.25 89/01/31 Copyr 1984 Sun Micro";
#include <rpc/rpc.h>
#include <sys/types.h>
#include <rpc/raw.h>
#include <assert.h>
#include <stdlib.h>
#ifdef __weak_alias
@ -248,6 +249,8 @@ svc_raw_ops(xprt)
extern mutex_t ops_lock;
#endif
_DIAGASSERT(xprt != NULL);
/* VARIABLES PROTECTED BY ops_lock: ops */
mutex_lock(&ops_lock);

View File

@ -1,4 +1,4 @@
/* $NetBSD: svc_simple.c,v 1.20 2000/07/06 03:10:35 christos Exp $ */
/* $NetBSD: svc_simple.c,v 1.21 2001/01/04 14:42:22 lukem Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
@ -51,10 +51,11 @@
#include <sys/types.h>
#include <rpc/rpc.h>
#include <rpc/nettype.h>
#include <assert.h>
#include <err.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <err.h>
#include "rpc_com.h"
@ -111,8 +112,6 @@ rpc_reg(prognum, versnum, procnum, progname, inproc, outproc, nettype)
extern mutex_t proglst_lock;
#endif
if (procnum == NULLPROC) {
warnx("%s can't reassign procedure number %u", rpc_reg_msg,
NULLPROC);
@ -254,6 +253,9 @@ universal(rqstp, transp)
extern mutex_t proglst_lock;
#endif
_DIAGASSERT(rqstp != NULL);
_DIAGASSERT(transp != NULL);
/*
* enforce "procnum 0 is echo" convention
*/