CVS commit: src/lib/libc/rpc

2021-04-12 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Tue Apr 13 00:29:22 UTC 2021

Modified Files:
src/lib/libc/rpc: getrpcent.c

Log Message:
pass dest buffer size to strncpy() and ensure nul termination.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/lib/libc/rpc/getrpcent.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/rpc/getrpcent.c
diff -u src/lib/libc/rpc/getrpcent.c:1.23 src/lib/libc/rpc/getrpcent.c:1.24
--- src/lib/libc/rpc/getrpcent.c:1.23	Mon Mar 11 20:19:29 2013
+++ src/lib/libc/rpc/getrpcent.c	Tue Apr 13 00:29:22 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: getrpcent.c,v 1.23 2013/03/11 20:19:29 tron Exp $	*/
+/*	$NetBSD: getrpcent.c,v 1.24 2021/04/13 00:29:22 mrg Exp $	*/
 
 /*
  * Copyright (c) 2010, Oracle America, Inc.
@@ -36,7 +36,7 @@
 #if 0
 static char *sccsid = "@(#)getrpcent.c 1.14 91/03/11 Copyr 1984 Sun Micro";
 #else
-__RCSID("$NetBSD: getrpcent.c,v 1.23 2013/03/11 20:19:29 tron Exp $");
+__RCSID("$NetBSD: getrpcent.c,v 1.24 2021/04/13 00:29:22 mrg Exp $");
 #endif
 #endif
 
@@ -185,7 +185,8 @@ interpret(char *val, size_t len)
 
 	if (d == 0)
 		return (0);
-	(void) strncpy(d->line, val, len);
+	strncpy(d->line, val, sizeof(d->line) - 1);
+	d->line[sizeof(d->line) - 1] = '\0';
 	p = d->line;
 	d->line[len] = '\n';
 	if (*p == '#')



CVS commit: src/lib/libc/rpc

2020-10-03 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Oct  3 18:31:29 UTC 2020

Modified Files:
src/lib/libc/rpc: Makefile.inc auth_unix.c rpc_clnt_auth.3

Log Message:
Add set_rpc_maxgrouplist


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/lib/libc/rpc/Makefile.inc \
src/lib/libc/rpc/auth_unix.c
cvs rdiff -u -r1.6 -r1.7 src/lib/libc/rpc/rpc_clnt_auth.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/rpc/Makefile.inc
diff -u src/lib/libc/rpc/Makefile.inc:1.26 src/lib/libc/rpc/Makefile.inc:1.27
--- src/lib/libc/rpc/Makefile.inc:1.26	Sun Oct 13 03:28:10 2019
+++ src/lib/libc/rpc/Makefile.inc	Sat Oct  3 14:31:29 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.inc,v 1.26 2019/10/13 07:28:10 mrg Exp $
+#	$NetBSD: Makefile.inc,v 1.27 2020/10/03 18:31:29 christos Exp $
 
 # librpc sources
 .PATH:	${.CURDIR}/rpc
@@ -38,6 +38,7 @@ MLINKS+=	bindresvport.3 bindresvport_sa.
 		rpc_clnt_auth.3 authnone_create.3 \
 		rpc_clnt_auth.3 authsys_create.3 \
 		rpc_clnt_auth.3 authsys_create_default.3 \
+		rpc_clnt_auth.3 set_rpc_maxgrouplist.3 \
 		rpc_clnt_calls.3 clnt_call.3 \
 		rpc_clnt_calls.3 clnt_perrno.3 \
 		rpc_clnt_calls.3 clnt_perror.3 \
Index: src/lib/libc/rpc/auth_unix.c
diff -u src/lib/libc/rpc/auth_unix.c:1.26 src/lib/libc/rpc/auth_unix.c:1.27
--- src/lib/libc/rpc/auth_unix.c:1.26	Sat Oct 18 04:33:23 2014
+++ src/lib/libc/rpc/auth_unix.c	Sat Oct  3 14:31:29 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: auth_unix.c,v 1.26 2014/10/18 08:33:23 snj Exp $	*/
+/*	$NetBSD: auth_unix.c,v 1.27 2020/10/03 18:31:29 christos Exp $	*/
 
 /*
  * Copyright (c) 2010, Oracle America, Inc.
@@ -37,7 +37,7 @@
 static char *sccsid = "@(#)auth_unix.c 1.19 87/08/11 Copyr 1984 Sun Micro";
 static char *sccsid = "@(#)auth_unix.c	2.2 88/08/01 4.0 RPCSRC";
 #else
-__RCSID("$NetBSD: auth_unix.c,v 1.26 2014/10/18 08:33:23 snj Exp $");
+__RCSID("$NetBSD: auth_unix.c,v 1.27 2020/10/03 18:31:29 christos Exp $");
 #endif
 #endif
 
@@ -183,6 +183,20 @@ authunix_create(char *machname, int uid,
 }
 
 /*
+ * Some servers will refuse mounts if the group list is larger
+ * than it expects (like 8). This allows the application to set
+ * the maximum size of the group list that will be sent.
+ */
+static int maxgrplist = NGROUPS;
+
+void
+set_rpc_maxgrouplist(int num)
+{
+	if (num < NGROUPS)
+		maxgrplist = num;
+}
+
+/*
  * Returns an auth handle with parameters determined by doing lots of
  * syscalls.
  */
@@ -202,6 +216,8 @@ authunix_create_default(void)
 	gid = getegid();
 	if ((len = getgroups(NGRPS, gids)) < 0)
 		abort();
+	if (len > maxgrplist)
+		len = maxgrplist;
 	/* XXX: interface problem; those should all have been unsigned */
 	return (authunix_create(machname, (int)uid, (int)gid, len,
 	(int *)gids));

Index: src/lib/libc/rpc/rpc_clnt_auth.3
diff -u src/lib/libc/rpc/rpc_clnt_auth.3:1.6 src/lib/libc/rpc/rpc_clnt_auth.3:1.7
--- src/lib/libc/rpc/rpc_clnt_auth.3:1.6	Wed Apr 16 09:34:43 2003
+++ src/lib/libc/rpc/rpc_clnt_auth.3	Sat Oct  3 14:31:29 2020
@@ -2,15 +2,16 @@
 .\" Copyright 1989 AT
 .\" @(#)rpc_clnt_auth 1.4 89/07/20 SMI;
 .\" Copyright (c) 1988 Sun Microsystems, Inc. - All Rights Reserved.
-.\"	$NetBSD: rpc_clnt_auth.3,v 1.6 2003/04/16 13:34:43 wiz Exp $
-.Dd May 7, 1993
+.\"	$NetBSD: rpc_clnt_auth.3,v 1.7 2020/10/03 18:31:29 christos Exp $
+.Dd October 3, 2020
 .Dt RPC_CLNT_AUTH 3
 .Os
 .Sh NAME
 .Nm auth_destroy ,
 .Nm authnone_create ,
 .Nm authsys_create ,
-.Nm authsys_create_default
+.Nm authsys_create_default ,
+.Nm set_rpc_maxgrouplist
 .Nd library routines for client side remote procedure call authentication
 .Sh LIBRARY
 .Lb libc
@@ -24,6 +25,8 @@
 .Fn authsys_create "const char *host" "const uid_t uid" "const gid_t gid" "const int len" "const gid_t *aup_gids"
 .Ft "AUTH *"
 .Fn authsys_create_default "void"
+.Ft "void"
+.Fn set_rpc_maxgrouplist "int num"
 .Sh DESCRIPTION
 These routines are part of the
 RPC library that allows C language programs to make procedure
@@ -90,6 +93,14 @@ refer to a counted array of groups to wh
 Call
 .Fn authsys_create
 with the appropriate parameters.
+.Pp
+.It Fn set_rpc_maxgrouplist
+Allow the application to set the maximum size of the group list
+that will be used in
+.Fn authunix_create_default to
+.Fa num .
+Some servers will refuse mounts if the group list is larger than it expects
+(like 8).
 .El
 .Sh SEE ALSO
 .Xr rpc 3 ,



CVS commit: src/lib/libc/rpc

2018-07-25 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Wed Jul 25 23:59:08 UTC 2018

Modified Files:
src/lib/libc/rpc: xdr_rec.c

Log Message:
Avoid undefined behavior in the definition of LAST_FRAG in xdr_rec.c

Do not change the signedness bit with a left shift operation.
Switch to unsigned integer to prevent this in the LAST_FRAG symbol.

xdr_rec.c:559:39, left shift of 1 by 31 places cannot be represented in type 
'int'
xdr_rec.c:572:26, left shift of 1 by 31 places cannot be represented in type 
'int'
xdr_rec.c:573:25, left shift of 1 by 31 places cannot be represented in type 
'int'
xdr_rec.c:632:37, left shift of 1 by 31 places cannot be represented in type 
'int'
xdr_rec.c:711:32, left shift of 1 by 31 places cannot be represented in type 
'int'
xdr_rec.c:722:28, left shift of 1 by 31 places cannot be represented in type 
'int'

Detected with micro-UBSan in the user mode.


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/lib/libc/rpc/xdr_rec.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/rpc/xdr_rec.c
diff -u src/lib/libc/rpc/xdr_rec.c:1.36 src/lib/libc/rpc/xdr_rec.c:1.37
--- src/lib/libc/rpc/xdr_rec.c:1.36	Thu Mar 26 11:31:57 2015
+++ src/lib/libc/rpc/xdr_rec.c	Wed Jul 25 23:59:08 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: xdr_rec.c,v 1.36 2015/03/26 11:31:57 justin Exp $	*/
+/*	$NetBSD: xdr_rec.c,v 1.37 2018/07/25 23:59:08 kamil Exp $	*/
 
 /*
  * Copyright (c) 2010, Oracle America, Inc.
@@ -37,7 +37,7 @@
 static char *sccsid = "@(#)xdr_rec.c 1.21 87/08/11 Copyr 1984 Sun Micro";
 static char *sccsid = "@(#)xdr_rec.c	2.2 88/08/01 4.0 RPCSRC";
 #else
-__RCSID("$NetBSD: xdr_rec.c,v 1.36 2015/03/26 11:31:57 justin Exp $");
+__RCSID("$NetBSD: xdr_rec.c,v 1.37 2018/07/25 23:59:08 kamil Exp $");
 #endif
 #endif
 
@@ -121,7 +121,7 @@ static const struct  xdr_ops xdrrec_ops 
  * meet the needs of xdr and rpc based on tcp.
  */
 
-#define LAST_FRAG ((uint32_t)(1 << 31))
+#define LAST_FRAG ((uint32_t)(1U << 31))
 
 typedef struct rec_strm {
 	char *tcp_handle;



CVS commit: src/lib/libc/rpc

2017-10-25 Thread Abhinav Upadhyay
Module Name:src
Committed By:   abhinav
Date:   Wed Oct 25 16:49:25 UTC 2017

Modified Files:
src/lib/libc/rpc: rpc_svc_calls.3

Log Message:
Add __svc_getcallercreds to the NAME section
Remove Pp before It at various places


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/lib/libc/rpc/rpc_svc_calls.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/rpc/rpc_svc_calls.3
diff -u src/lib/libc/rpc/rpc_svc_calls.3:1.12 src/lib/libc/rpc/rpc_svc_calls.3:1.13
--- src/lib/libc/rpc/rpc_svc_calls.3:1.12	Mon Mar 22 19:30:54 2010
+++ src/lib/libc/rpc/rpc_svc_calls.3	Wed Oct 25 16:49:24 2017
@@ -2,7 +2,7 @@
 .\" Copyright 1989 AT
 .\" @(#)rpc_svc_calls 1.5 89/07/25 SMI;
 .\" Copyright (c) 1988 Sun Microsystems, Inc. - All Rights Reserved.
-.\"	$NetBSD: rpc_svc_calls.3,v 1.12 2010/03/22 19:30:54 joerg Exp $
+.\"	$NetBSD: rpc_svc_calls.3,v 1.13 2017/10/25 16:49:24 abhinav Exp $
 .Dd May 3, 1993
 .Dt RPC_SVC_CALLS 3
 .Os
@@ -16,6 +16,7 @@
 .Nm svc_getreq_poll ,
 .Nm svc_getreqset ,
 .Nm svc_getrpccaller ,
+.Nm __svc_getcallercreds ,
 .Nm svc_pollset ,
 .Nm svc_run ,
 .Nm svc_sendreply
@@ -73,7 +74,6 @@ See
 for the definition of the
 .Dv SVCXPRT
 data structure.
-.Pp
 .Bl -tag -width __svc_getcallercreds()
 .It Fn svc_dg_enablecache
 This function allocates a duplicate request cache for the
@@ -119,7 +119,6 @@ This variable is read-only (do not pass 
 yet it may change after calls to
 .Fn svc_getreqset
 or any creation routines.
-.Pp
 .It Fn svc_freeargs
 A function macro that frees any data allocated by the
 RPC/XDR system when it decoded the arguments to a service procedure
@@ -131,7 +130,6 @@ if the results were successfully
 freed, and
 .Dv FALSE
 otherwise.
-.Pp
 .It Fn svc_getargs
 A function macro that decodes the arguments of an
 RPC request associated with the RPC
@@ -151,7 +149,6 @@ otherwise.
 .It Fn svc_getreq_common
 This routine is called to handle a request on the given
 file descriptor.
-.Pp
 .It Fn svc_getreq_poll
 This routine is only of interest if a service implementor
 does not call
@@ -173,7 +170,6 @@ structures on which the
 was done.
 It is assumed to be an array large enough to
 contain the maximal number of descriptors allowed.
-.Pp
 .It Fn svc_getreqset
 This routine is only of interest if a service implementor
 does not call
@@ -189,13 +185,11 @@ The routine returns when all file descri
 associated with the value of
 .Fa rdfds
 have been serviced.
-.Pp
 .It Fn svc_getrpccaller
 The approved way of getting the network address of the caller
 of a procedure associated with the
 RPC service transport handle
 .Fa xprt .
-.Pp
 .It Fn __svc_getcallercreds
 .Em Warning: this macro is specific to
 .Nx
@@ -224,7 +218,6 @@ is made in the current implementation in
 Service implementors who do not call
 .Fn svc_run
 and who wish to use this array must perform this derivation themselves.
-.Pp
 .It Fn svc_run
 This routine never returns.
 It waits for RPC
@@ -235,7 +228,6 @@ when one arrives.
 This procedure is usually waiting for the
 .Xr poll 2
 system call to return.
-.Pp
 .It Fn svc_sendreply
 Called by an RPC service's dispatch routine to send the results of a
 remote procedure call.



CVS commit: src/lib/libc/rpc

2017-08-12 Thread Brian Ginsbach
Module Name:src
Committed By:   ginsbach
Date:   Sun Aug 13 01:08:41 UTC 2017

Modified Files:
src/lib/libc/rpc: rpcb_st_xdr.c

Log Message:
PR lib/15802: Shuuichirou Murata: Add missing xdr_rpcbs_rmtcalllist_ptr

There was a missing call to xdr_rpcbs_rmtcalllist_ptr in xdr_rpcb_stat.
This fixes issues with RPCBPROC_GETSTAT not working correctly with
systems that correctly implement the XDR encode/decode routine.

XXX: pullup-8
XXX: pullup-7
XXX: pullup-6


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/lib/libc/rpc/rpcb_st_xdr.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/rpc/rpcb_st_xdr.c
diff -u src/lib/libc/rpc/rpcb_st_xdr.c:1.11 src/lib/libc/rpc/rpcb_st_xdr.c:1.12
--- src/lib/libc/rpc/rpcb_st_xdr.c:1.11	Wed May  3 21:39:27 2017
+++ src/lib/libc/rpc/rpcb_st_xdr.c	Sun Aug 13 01:08:41 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: rpcb_st_xdr.c,v 1.11 2017/05/03 21:39:27 christos Exp $	*/
+/*	$NetBSD: rpcb_st_xdr.c,v 1.12 2017/08/13 01:08:41 ginsbach Exp $	*/
 
 /*
  * Copyright (c) 2010, Oracle America, Inc.
@@ -42,7 +42,7 @@
 
 #include 
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: rpcb_st_xdr.c,v 1.11 2017/05/03 21:39:27 christos Exp $");
+__RCSID("$NetBSD: rpcb_st_xdr.c,v 1.12 2017/08/13 01:08:41 ginsbach Exp $");
 #endif
 
 #include "namespace.h"
@@ -258,6 +258,9 @@ xdr_rpcb_stat(XDR *xdrs, rpcb_stat *objp
 	if (!xdr_rpcbs_addrlist_ptr(xdrs, >addrinfo)) {
 		return (FALSE);
 	}
+	if (!xdr_rpcbs_rmtcalllist_ptr(xdrs, >rmtinfo)) {
+		return (FALSE);
+	}
 	return (TRUE);
 }
 



CVS commit: src/lib/libc/rpc

2017-06-30 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Jun 30 10:03:34 UTC 2017

Modified Files:
src/lib/libc/rpc: getnetconfig.c

Log Message:
Revert previous since it causes a double free (p->nc_netid == tmp == tmp2).
>From Xin Li @ FreeBSD.
XXX: pullup 7


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/lib/libc/rpc/getnetconfig.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/rpc/getnetconfig.c
diff -u src/lib/libc/rpc/getnetconfig.c:1.24 src/lib/libc/rpc/getnetconfig.c:1.25
--- src/lib/libc/rpc/getnetconfig.c:1.24	Wed Oct 26 11:39:30 2016
+++ src/lib/libc/rpc/getnetconfig.c	Fri Jun 30 06:03:34 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: getnetconfig.c,v 1.24 2016/10/26 15:39:30 christos Exp $	*/
+/*	$NetBSD: getnetconfig.c,v 1.25 2017/06/30 10:03:34 christos Exp $	*/
 
 /*
  * Copyright (c) 2010, Oracle America, Inc.
@@ -36,7 +36,7 @@
 #if 0
 staticchar sccsid[] = "@(#)getnetconfig.c	1.12 91/12/19 SMI";
 #else
-__RCSID("$NetBSD: getnetconfig.c,v 1.24 2016/10/26 15:39:30 christos Exp $");
+__RCSID("$NetBSD: getnetconfig.c,v 1.25 2017/06/30 10:03:34 christos Exp $");
 #endif
 #endif
 
@@ -649,12 +649,12 @@ static struct netconfig *
 dup_ncp(struct netconfig *ncp)
 {
 	struct netconfig	*p;
-	char	*tmp, *tmp2;
+	char	*tmp;
 	u_int	i;
 
 	_DIAGASSERT(ncp != NULL);
 
-	if ((tmp2 = tmp = malloc(MAXNETCONFIGLINE)) == NULL)
+	if ((tmp = malloc(MAXNETCONFIGLINE)) == NULL)
 		return NULL;
 	if ((p = malloc(sizeof(*p))) == NULL) {
 		free(tmp);
@@ -679,7 +679,6 @@ dup_ncp(struct netconfig *ncp)
 	p->nc_device = strcpy(tmp, ncp->nc_device);
 	p->nc_lookups = calloc((size_t)(p->nc_nlookups + 1), sizeof(char *));
 	if (p->nc_lookups == NULL) {
-		free(tmp2);
 		free(p->nc_netid);
 		free(p);
 		return NULL;



CVS commit: src/lib/libc/rpc

2017-05-03 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed May  3 21:39:27 UTC 2017

Modified Files:
src/lib/libc/rpc: rpc_generic.c rpcb_prot.c rpcb_st_xdr.c xdr.c

Log Message:
- limit size of buffers to RPC_MAXDATASIZE
- don't leak memory
- be more picky about bad parameters
https://raw.githubusercontent.com/guidovranken/rpcbomb/master/libtirpc_patch.txt

XXX: pullup-7


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/lib/libc/rpc/rpc_generic.c
cvs rdiff -u -r1.11 -r1.12 src/lib/libc/rpc/rpcb_prot.c
cvs rdiff -u -r1.10 -r1.11 src/lib/libc/rpc/rpcb_st_xdr.c
cvs rdiff -u -r1.33 -r1.34 src/lib/libc/rpc/xdr.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/rpc/rpc_generic.c
diff -u src/lib/libc/rpc/rpc_generic.c:1.29 src/lib/libc/rpc/rpc_generic.c:1.30
--- src/lib/libc/rpc/rpc_generic.c:1.29	Thu Apr  4 23:17:38 2013
+++ src/lib/libc/rpc/rpc_generic.c	Wed May  3 17:39:27 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: rpc_generic.c,v 1.29 2013/04/05 03:17:38 dholland Exp $	*/
+/*	$NetBSD: rpc_generic.c,v 1.30 2017/05/03 21:39:27 christos Exp $	*/
 
 /*
  * Copyright (c) 2010, Oracle America, Inc.
@@ -43,7 +43,7 @@
 
 #include 
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: rpc_generic.c,v 1.29 2013/04/05 03:17:38 dholland Exp $");
+__RCSID("$NetBSD: rpc_generic.c,v 1.30 2017/05/03 21:39:27 christos Exp $");
 #endif
 
 #include "namespace.h"
@@ -644,6 +644,9 @@ __rpc_taddr2uaddr_af(int af, const struc
 
 	switch (af) {
 	case AF_INET:
+		if (nbuf->len < sizeof(*sinp)) {
+			return NULL;
+		}
 		sinp = nbuf->buf;
 		if (inet_ntop(af, >sin_addr, namebuf,
 		(socklen_t)sizeof namebuf) == NULL)
@@ -655,6 +658,9 @@ __rpc_taddr2uaddr_af(int af, const struc
 		break;
 #ifdef INET6
 	case AF_INET6:
+		if (nbuf->len < sizeof(*sin6)) {
+			return NULL;
+		}
 		sin6 = nbuf->buf;
 		if (inet_ntop(af, >sin6_addr, namebuf6,
 		(socklen_t)sizeof namebuf6) == NULL)
@@ -690,7 +696,8 @@ __rpc_uaddr2taddr_af(int af, const char 
 #endif
 	struct sockaddr_un *sun;
 
-	_DIAGASSERT(uaddr != NULL);
+	if (uaddr == NULL)
+		return NULL;
 
 	addrstr = strdup(uaddr);
 	if (addrstr == NULL)

Index: src/lib/libc/rpc/rpcb_prot.c
diff -u src/lib/libc/rpc/rpcb_prot.c:1.11 src/lib/libc/rpc/rpcb_prot.c:1.12
--- src/lib/libc/rpc/rpcb_prot.c:1.11	Mon Mar 11 16:19:29 2013
+++ src/lib/libc/rpc/rpcb_prot.c	Wed May  3 17:39:27 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: rpcb_prot.c,v 1.11 2013/03/11 20:19:29 tron Exp $	*/
+/*	$NetBSD: rpcb_prot.c,v 1.12 2017/05/03 21:39:27 christos Exp $	*/
 
 /*
  * Copyright (c) 2010, Oracle America, Inc.
@@ -41,7 +41,7 @@
 #if 0
 static char sccsid[] = "@(#)rpcb_prot.c 1.9 89/04/21 Copyr 1984 Sun Micro";
 #else
-__RCSID("$NetBSD: rpcb_prot.c,v 1.11 2013/03/11 20:19:29 tron Exp $");
+__RCSID("$NetBSD: rpcb_prot.c,v 1.12 2017/05/03 21:39:27 christos Exp $");
 #endif
 #endif
 
@@ -58,6 +58,7 @@ __RCSID("$NetBSD: rpcb_prot.c,v 1.11 201
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -85,13 +86,13 @@ xdr_rpcb(XDR *xdrs, RPCB *objp)
 	if (!xdr_u_int32_t(xdrs, >r_vers)) {
 		return (FALSE);
 	}
-	if (!xdr_string(xdrs, >r_netid, (u_int)~0)) {
+	if (!xdr_string(xdrs, >r_netid, RPC_MAXDATASIZE)) {
 		return (FALSE);
 	}
-	if (!xdr_string(xdrs, >r_addr, (u_int)~0)) {
+	if (!xdr_string(xdrs, >r_addr, RPC_MAXDATASIZE)) {
 		return (FALSE);
 	}
-	if (!xdr_string(xdrs, >r_owner, (u_int)~0)) {
+	if (!xdr_string(xdrs, >r_owner, RPC_MAXDATASIZE)) {
 		return (FALSE);
 	}
 	return (TRUE);
@@ -193,19 +194,19 @@ xdr_rpcb_entry(XDR *xdrs, rpcb_entry *ob
 
 	_DIAGASSERT(objp != NULL);
 
-	if (!xdr_string(xdrs, >r_maddr, (u_int)~0)) {
+	if (!xdr_string(xdrs, >r_maddr, RPC_MAXDATASIZE)) {
 		return (FALSE);
 	}
-	if (!xdr_string(xdrs, >r_nc_netid, (u_int)~0)) {
+	if (!xdr_string(xdrs, >r_nc_netid, RPC_MAXDATASIZE)) {
 		return (FALSE);
 	}
 	if (!xdr_u_int32_t(xdrs, >r_nc_semantics)) {
 		return (FALSE);
 	}
-	if (!xdr_string(xdrs, >r_nc_protofmly, (u_int)~0)) {
+	if (!xdr_string(xdrs, >r_nc_protofmly, RPC_MAXDATASIZE)) {
 		return (FALSE);
 	}
-	if (!xdr_string(xdrs, >r_nc_proto, (u_int)~0)) {
+	if (!xdr_string(xdrs, >r_nc_proto, RPC_MAXDATASIZE)) {
 		return (FALSE);
 	}
 	return (TRUE);
@@ -329,7 +330,7 @@ xdr_rpcb_rmtcallres(XDR *xdrs, struct rp
 
 	_DIAGASSERT(p != NULL);
 
-	if (!xdr_string(xdrs, >addr, (u_int)~0)) {
+	if (!xdr_string(xdrs, >addr, RPC_MAXDATASIZE)) {
 		return (FALSE);
 	}
 	if (!xdr_u_int(xdrs, >results.results_len)) {
@@ -349,6 +350,11 @@ xdr_netbuf(XDR *xdrs, struct netbuf *obj
 	if (!xdr_u_int32_t(xdrs, (u_int32_t *) >maxlen)) {
 		return (FALSE);
 	}
+
+	if (objp->maxlen > RPC_MAXDATASIZE) {
+		return (FALSE);
+	}
+
 	dummy = xdr_bytes(xdrs, (char **)(void *)&(objp->buf),
 			(u_int *)&(objp->len), objp->maxlen);
 	return (dummy);

Index: src/lib/libc/rpc/rpcb_st_xdr.c
diff -u src/lib/libc/rpc/rpcb_st_xdr.c:1.10 src/lib/libc/rpc/rpcb_st_xdr.c:1.11
--- 

CVS commit: src/lib/libc/rpc

2017-04-18 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Tue Apr 18 11:35:34 UTC 2017

Modified Files:
src/lib/libc/rpc: svc_fdset.c

Log Message:
avoid calloc(1,0).
from clang static analyzer

ok christos


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/lib/libc/rpc/svc_fdset.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/rpc/svc_fdset.c
diff -u src/lib/libc/rpc/svc_fdset.c:1.15 src/lib/libc/rpc/svc_fdset.c:1.16
--- src/lib/libc/rpc/svc_fdset.c:1.15	Tue Nov 10 20:56:20 2015
+++ src/lib/libc/rpc/svc_fdset.c	Tue Apr 18 11:35:34 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: svc_fdset.c,v 1.15 2015/11/10 20:56:20 christos Exp $	*/
+/*	$NetBSD: svc_fdset.c,v 1.16 2017/04/18 11:35:34 maya Exp $	*/
 
 /*-
  * Copyright (c) 2015 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: svc_fdset.c,v 1.15 2015/11/10 20:56:20 christos Exp $");
+__RCSID("$NetBSD: svc_fdset.c,v 1.16 2017/04/18 11:35:34 maya Exp $");
 
 
 #include "reentrant.h"
@@ -387,6 +387,8 @@ fd_set *
 svc_fdset_copy(const fd_set *orig)
 {
 	int size = svc_fdset_getsize(0);
+	if (size == -1)
+		return NULL;
 	fd_set *copy = calloc(1, __NFD_BYTES(size));
 	if (copy == NULL)
 		return NULL;



CVS commit: src/lib/libc/rpc

2017-01-10 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Jan 10 17:45:27 UTC 2017

Modified Files:
src/lib/libc/rpc: svc_run.c

Log Message:
use correct type for poll


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/lib/libc/rpc/svc_run.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/rpc/svc_run.c
diff -u src/lib/libc/rpc/svc_run.c:1.27 src/lib/libc/rpc/svc_run.c:1.28
--- src/lib/libc/rpc/svc_run.c:1.27	Tue Nov 10 15:56:20 2015
+++ src/lib/libc/rpc/svc_run.c	Tue Jan 10 12:45:27 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: svc_run.c,v 1.27 2015/11/10 20:56:20 christos Exp $	*/
+/*	$NetBSD: svc_run.c,v 1.28 2017/01/10 17:45:27 christos Exp $	*/
 
 /*
  * Copyright (c) 2010, Oracle America, Inc.
@@ -37,7 +37,7 @@
 static char *sccsid = "@(#)svc_run.c 1.1 87/10/13 Copyr 1984 Sun Micro";
 static char *sccsid = "@(#)svc_run.c	2.1 88/07/29 4.0 RPCSRC";
 #else
-__RCSID("$NetBSD: svc_run.c,v 1.27 2015/11/10 20:56:20 christos Exp $");
+__RCSID("$NetBSD: svc_run.c,v 1.28 2017/01/10 17:45:27 christos Exp $");
 #endif
 #endif
 
@@ -169,7 +169,7 @@ svc_run_poll(void)
 
 		rwlock_unlock(_fd_lock);
 
-		switch ((i = poll(pfd, (size_t)*maxfd, 30 * 1000))) {
+		switch ((i = poll(pfd, (nfds_t)*maxfd, 30 * 1000))) {
 		case -1:
 #ifndef RUMP_RPC		
 			if ((errno == EINTR || errno == EBADF) && probs < 100) {



CVS commit: src/lib/libc/rpc

2016-12-29 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Thu Dec 29 22:07:12 UTC 2016

Modified Files:
src/lib/libc/rpc: rpc_soc.3

Log Message:
Update prototypes to match current RPC code.
Bump date.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/lib/libc/rpc/rpc_soc.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/rpc/rpc_soc.3
diff -u src/lib/libc/rpc/rpc_soc.3:1.15 src/lib/libc/rpc/rpc_soc.3:1.16
--- src/lib/libc/rpc/rpc_soc.3:1.15	Mon Aug  8 04:16:45 2016
+++ src/lib/libc/rpc/rpc_soc.3	Thu Dec 29 22:07:12 2016
@@ -1,8 +1,8 @@
 .\"	@(#)rpc.3n	2.4 88/08/08 4.0 RPCSRC; from 1.19 88/06/24 SMI
-.\"	$NetBSD: rpc_soc.3,v 1.15 2016/08/08 04:16:45 dholland Exp $
+.\"	$NetBSD: rpc_soc.3,v 1.16 2016/12/29 22:07:12 wiz Exp $
 .\" Converted to mdoc by Thomas Klausner 
 .\"
-.Dd December 12, 2008
+.Dd December 29, 2016
 .Dt RPC_SOC 3
 .Os
 .Sh NAME
@@ -81,8 +81,8 @@
 .Ft AUTH *
 .Fn authunix_create_default "void"
 .Ft int
-.Fn callrpc "char *host" "u_long prognum" "u_long versnum" \
-"u_long procnum" "xdrproc_t inproc" "char *in" "xdrproc_t outproc" "char *out"
+.Fn callrpc "char *host" "int prognum" "int versnum" \
+"int procnum" "xdrproc_t inproc" "char *in" "xdrproc_t outproc" "char *out"
 .Ft enum clnt_stat
 .Fn clnt_broadcast "u_long prognum" "u_long versnum" "u_long procnum" \
 "xdrproc_t inproc" "char *in" "xdrproc_t outproc" "char *out" \
@@ -93,7 +93,7 @@
 .Ft int
 .Fn clnt_destroy "CLIENT *clnt"
 .Ft CLIENT *
-.Fn clnt_create "char *host" "u_long prog" "u_long vers" "char *proto"
+.Fn clnt_create "const char *host" "rpcprog_t prog" "rpcvers_t vers" "const char *proto"
 .Ft bool_t
 .Fn clnt_control "CLIENT *cl" "u_int req" "char *info"
 .Ft int
@@ -101,17 +101,17 @@
 .Ft void
 .Fn clnt_geterr "CLIENT *clnt" "struct rpc_err errp"
 .Ft void
-.Fn clnt_pcreateerror "char *s"
+.Fn clnt_pcreateerror "const char *s"
 .Ft void
 .Fn clnt_perrno "enum clnt_stat stat"
-.Ft int
-.Fn clnt_perror "CLIENT *clnt" "char *s"
+.Ft void
+.Fn clnt_perror "CLIENT *clnt" "const char *s"
 .Ft char *
 .Fn clnt_spcreateerror "const char *s"
 .Ft char *
 .Fn clnt_sperrno "enum clnt_stat stat"
 .Ft char *
-.Fn clnt_sperror "CLIENT *rpch" "char *s"
+.Fn clnt_sperror "CLIENT *rpch" "const char *s"
 .Ft CLIENT *
 .Fn clntraw_create "u_long prognum" "u_long versnum"
 .Ft CLIENT *
@@ -130,7 +130,7 @@
 .Fn pmap_getmaps "struct sockaddr_in *addr"
 .Ft u_short
 .Fn pmap_getport "struct sockaddr_in *addr" "u_long prognum" \
-"u_long versnum" "u_long protocol"
+"u_long versnum" "u_int protocol"
 .Ft enum clnt_stat
 .Fo pmap_rmtcall
 .Fa "struct sockaddr_in *addr"
@@ -139,7 +139,7 @@
 .Fa "u_long procnum"
 .Fa "xdrproc_t inproc"
 .Fa "char *in"
-.Fa "xdrpoc_t outproc"
+.Fa "xdrproc_t outproc"
 .Fa "char *out"
 .Fa "struct timeval tout"
 .Fa "u_long *portp"
@@ -150,7 +150,7 @@
 .Ft int
 .Fn pmap_unset "u_long prognum" "u_long versnum"
 .Ft int
-.Fn registerrpc "u_long prognum" "u_long versnum" "u_long procnum" \
+.Fn registerrpc "int prognum" "int versnum" "int procnum" \
 "char *(*procname)()" "xdrproc_t inproc" "xdrproc_t outproc"
 .Fd struct rpc_createerr rpc_createerr;
 .Ft int
@@ -163,19 +163,19 @@
 .Fn svc_getargs "SVCXPRT *xprt" "xdrproc_t inproc" "char *in"
 .Ft struct sockaddr_in *
 .Fn svc_getcaller "SVCXPRT *xprt"
-.Ft int
+.Ft void
 .Fn svc_getreqset "fd_set *rdfds"
-.Ft int
+.Ft void
 .Fn svc_getreq "int rdfds"
 .Ft struct netbuf *
 .Fn svc_getrpccaller "SVCXPRT *xprt"
-.Ft int
+.Ft bool_t
 .Fn svc_register "SVCXPRT *xprt" "u_long prognum" "u_long versnum" \
-"void (*dispatch)()" "u_long protocol"
-.Ft int
+"void (*dispatch)()" "int protocol"
+.Ft void
 .Fn svc_run "void"
-.Ft int
-.Fn svc_sendreply "SVCXPRT *xprt" "xdrproc_t outproc" "char *out"
+.Ft bool_t
+.Fn svc_sendreply "SVCXPRT *xprt" "xdrproc_t xdr_results" "const char *location"
 .Ft void
 .Fn svc_unregister "u_long prognum" "u_long versnum"
 .Ft void
@@ -187,7 +187,7 @@
 .Ft void
 .Fn svcerr_noprog "SVCXPRT *xprt"
 .Ft void
-.Fn svcerr_progvers "SVCXPRT *xprt"
+.Fn svcerr_progvers "SVCXPRT *xprt" "rpcvers_t low_vers" "rpcvers_t high_vers"
 .Ft void
 .Fn svcerr_systemerr "SVCXPRT *xprt"
 .Ft void
@@ -207,7 +207,7 @@
 .Fn xdr_accepted_reply "XDR *xdrs" "struct accepted_reply *ar"
 .Ft int
 .Fn xdr_authunix_parms "XDR *xdrs" "struct authunix_parms *aupp"
-.Ft void
+.Ft bool_t
 .Fn xdr_callhdr "XDR *xdrs" "struct rpc_msg *chdr"
 .Ft int
 .Fn xdr_callmsg "XDR *xdrs" "struct rpc_msg *cmsg"
@@ -877,9 +877,9 @@ remote procedure call.
 The parameter
 .Fa xprt
 is the request's associated transport handle;
-.Fa outproc
+.Fa xdr_results
 is the XDR routine which is used to encode the results; and
-.Fa out
+.Fa xdr_location
 is the address of the results.
 This routine returns one if it succeeds, zero otherwise.
 .It Fn svc_unregister
@@ -910,6 +910,7 @@ Service implementors usually do not need
 Called when the desired version of a 

CVS commit: src/lib/libc/rpc

2016-10-26 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Oct 26 15:39:30 UTC 2016

Modified Files:
src/lib/libc/rpc: getnetconfig.c

Log Message:
PR/51578: Henning Petersen: Fix leak on error.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/lib/libc/rpc/getnetconfig.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/rpc/getnetconfig.c
diff -u src/lib/libc/rpc/getnetconfig.c:1.23 src/lib/libc/rpc/getnetconfig.c:1.24
--- src/lib/libc/rpc/getnetconfig.c:1.23	Wed Oct 26 11:36:17 2016
+++ src/lib/libc/rpc/getnetconfig.c	Wed Oct 26 11:39:30 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: getnetconfig.c,v 1.23 2016/10/26 15:36:17 christos Exp $	*/
+/*	$NetBSD: getnetconfig.c,v 1.24 2016/10/26 15:39:30 christos Exp $	*/
 
 /*
  * Copyright (c) 2010, Oracle America, Inc.
@@ -36,7 +36,7 @@
 #if 0
 staticchar sccsid[] = "@(#)getnetconfig.c	1.12 91/12/19 SMI";
 #else
-__RCSID("$NetBSD: getnetconfig.c,v 1.23 2016/10/26 15:36:17 christos Exp $");
+__RCSID("$NetBSD: getnetconfig.c,v 1.24 2016/10/26 15:39:30 christos Exp $");
 #endif
 #endif
 
@@ -649,12 +649,12 @@ static struct netconfig *
 dup_ncp(struct netconfig *ncp)
 {
 	struct netconfig	*p;
-	char	*tmp;
+	char	*tmp, *tmp2;
 	u_int	i;
 
 	_DIAGASSERT(ncp != NULL);
 
-	if ((tmp = malloc(MAXNETCONFIGLINE)) == NULL)
+	if ((tmp2 = tmp = malloc(MAXNETCONFIGLINE)) == NULL)
 		return NULL;
 	if ((p = malloc(sizeof(*p))) == NULL) {
 		free(tmp);
@@ -679,6 +679,7 @@ dup_ncp(struct netconfig *ncp)
 	p->nc_device = strcpy(tmp, ncp->nc_device);
 	p->nc_lookups = calloc((size_t)(p->nc_nlookups + 1), sizeof(char *));
 	if (p->nc_lookups == NULL) {
+		free(tmp2);
 		free(p->nc_netid);
 		free(p);
 		return NULL;



CVS commit: src/lib/libc/rpc

2016-10-26 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Oct 26 15:36:17 UTC 2016

Modified Files:
src/lib/libc/rpc: getnetconfig.c

Log Message:
KNF, no real change (except malloc(x * y) -> calloc(x, y))


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/lib/libc/rpc/getnetconfig.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/rpc/getnetconfig.c
diff -u src/lib/libc/rpc/getnetconfig.c:1.22 src/lib/libc/rpc/getnetconfig.c:1.23
--- src/lib/libc/rpc/getnetconfig.c:1.22	Thu Sep 18 09:58:20 2014
+++ src/lib/libc/rpc/getnetconfig.c	Wed Oct 26 11:36:17 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: getnetconfig.c,v 1.22 2014/09/18 13:58:20 christos Exp $	*/
+/*	$NetBSD: getnetconfig.c,v 1.23 2016/10/26 15:36:17 christos Exp $	*/
 
 /*
  * Copyright (c) 2010, Oracle America, Inc.
@@ -36,7 +36,7 @@
 #if 0
 staticchar sccsid[] = "@(#)getnetconfig.c	1.12 91/12/19 SMI";
 #else
-__RCSID("$NetBSD: getnetconfig.c,v 1.22 2014/09/18 13:58:20 christos Exp $");
+__RCSID("$NetBSD: getnetconfig.c,v 1.23 2016/10/26 15:36:17 christos Exp $");
 #endif
 #endif
 
@@ -174,7 +174,7 @@ __nc_error(void)
 		nc_addr = malloc(sizeof (int));
 		if (nc_addr == NULL)
 			return _error;
-		if (thr_setspecific(nc_key, (void *) nc_addr) != 0) {
+		if (thr_setspecific(nc_key, nc_addr) != 0) {
 			if (nc_addr)
 free(nc_addr);
 			return _error;
@@ -213,7 +213,7 @@ setnetconfig(void)
 	struct netconfig_vars *nc_vars;
 
 	if ((nc_vars = malloc(sizeof(*nc_vars))) == NULL) {
-		return(NULL);
+		return NULL;
 	}
 
 	/*
@@ -225,12 +225,12 @@ setnetconfig(void)
 		nc_vars->valid = NC_VALID;
 		nc_vars->flag = 0;
 		nc_vars->nc_configs = ni.head;
-		return ((void *)nc_vars);
+		return nc_vars;
 	}
 	ni.ref--;
 	nc_error = NC_NONETCONFIG;
 	free(nc_vars);
-	return (NULL);
+	return NULL;
 }
 
 
@@ -245,7 +245,7 @@ setnetconfig(void)
 struct netconfig *
 getnetconfig(void *handlep)
 {
-	struct netconfig_vars *ncp = (struct netconfig_vars *)handlep;
+	struct netconfig_vars *ncp = handlep;
 	char *stringp;		/* tmp string pointer */
 	struct netconfig_list	*list;
 	struct netconfig *np;
@@ -255,7 +255,7 @@ getnetconfig(void *handlep)
 	 */
 	if (ncp == NULL || nc_file == NULL) {
 		nc_error = NC_NOTINIT;
-		return (NULL);
+		return NULL;
 	}
 
 	switch (ncp->valid) {
@@ -273,12 +273,12 @@ getnetconfig(void *handlep)
 			ncp->flag = 1;
 			ncp->nc_configs = ni.head;
 			if (ncp->nc_configs != NULL) /* entry already exist */
-return(ncp->nc_configs->ncp);
+return ncp->nc_configs->ncp;
 		}
 		else if (ncp->nc_configs != NULL &&
 		ncp->nc_configs->next != NULL) {
 			ncp->nc_configs = ncp->nc_configs->next;
-			return(ncp->nc_configs->ncp);
+			return ncp->nc_configs->ncp;
 		}
 
 		/*
@@ -286,16 +286,16 @@ getnetconfig(void *handlep)
 		 * we give up.
 		 */
 		if (ni.eof == 1)
-			return(NULL);
+			return NULL;
 		break;
 	default:
 		nc_error = NC_NOTINIT;
-		return (NULL);
+		return NULL;
 	}
 
 	stringp = malloc(MAXNETCONFIGLINE);
 	if (stringp == NULL)
-		return (NULL);
+		return NULL;
 
 #ifdef MEM_CHK
 	if (malloc_verify() == 0) {
@@ -311,20 +311,20 @@ getnetconfig(void *handlep)
 		if (fgets(stringp, MAXNETCONFIGLINE, nc_file) == NULL) {
 			free(stringp);
 			ni.eof = 1;
-			return (NULL);
+			return NULL;
 		}
 	} while (*stringp == '#');
 
 	list = malloc(sizeof(*list));
 	if (list == NULL) {
 		free(stringp);
-		return(NULL);
+		return NULL;
 	}
 	np = malloc(sizeof(*np));
 	if (np == NULL) {
 		free(stringp);
 		free(list);
-		return(NULL);
+		return NULL;
 	}
 	list->ncp = np;
 	list->next = NULL;
@@ -334,7 +334,7 @@ getnetconfig(void *handlep)
 		free(stringp);
 		free(np);
 		free(list);
-		return (NULL);
+		return NULL;
 	} else {
 		/*
 		 * If this is the first entry that's been read, it is the
@@ -349,7 +349,7 @@ getnetconfig(void *handlep)
 			ni.tail = ni.tail->next;
 		}
 		ncp->nc_configs = ni.tail;
-		return(ni.tail->ncp);
+		return ni.tail->ncp;
 	}
 }
 
@@ -363,7 +363,7 @@ getnetconfig(void *handlep)
 int
 endnetconfig(void *handlep)
 {
-	struct netconfig_vars *nc_handlep = (struct netconfig_vars *)handlep;
+	struct netconfig_vars *nc_handlep = handlep;
 
 	struct netconfig_list *q, *p;
 
@@ -373,7 +373,7 @@ endnetconfig(void *handlep)
 	if (nc_handlep == NULL || (nc_handlep->valid != NC_VALID &&
 	nc_handlep->valid != NC_STORAGE)) {
 		nc_error = NC_NOTINIT;
-		return (-1);
+		return -1;
 	}
 
 	/*
@@ -384,7 +384,7 @@ endnetconfig(void *handlep)
 	nc_handlep->nc_configs = NULL;
 	if (--ni.ref > 0) {
 		free(nc_handlep);
-		return(0);
+		return 0;
 	}
 
 	/*
@@ -408,7 +408,7 @@ endnetconfig(void *handlep)
 
 	fclose(nc_file);
 	nc_file = NULL;
-	return (0);
+	return 0;
 }
 
 /*
@@ -429,7 +429,7 @@ getnetconfigent(const char *netid)
 	struct netconfig_list *list;	/* pointer to cache list */
 
 	if (netid == NULL || strlen(netid) == 0)
-		return (NULL);
+		return NULL;
 
 	/*
 	 * Look 

CVS commit: src/lib/libc/rpc

2016-08-07 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Mon Aug  8 04:16:45 UTC 2016

Modified Files:
src/lib/libc/rpc: rpc_soc.3

Log Message:
Typo.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/lib/libc/rpc/rpc_soc.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/rpc/rpc_soc.3
diff -u src/lib/libc/rpc/rpc_soc.3:1.14 src/lib/libc/rpc/rpc_soc.3:1.15
--- src/lib/libc/rpc/rpc_soc.3:1.14	Mon Mar  4 17:29:03 2013
+++ src/lib/libc/rpc/rpc_soc.3	Mon Aug  8 04:16:45 2016
@@ -1,5 +1,5 @@
 .\"	@(#)rpc.3n	2.4 88/08/08 4.0 RPCSRC; from 1.19 88/06/24 SMI
-.\"	$NetBSD: rpc_soc.3,v 1.14 2013/03/04 17:29:03 christos Exp $
+.\"	$NetBSD: rpc_soc.3,v 1.15 2016/08/08 04:16:45 dholland Exp $
 .\" Converted to mdoc by Thomas Klausner 
 .\"
 .Dd December 12, 2008
@@ -986,8 +986,8 @@ This allows the user to specify the maxi
 receiving UDP-based RPC messages.
 .It Fn svcudp_create
 This acts as
-.Fn svcudp_bufcreate with
-predefined sizes for the maximum packet sizes.
+.Fn svcudp_bufcreate
+with predefined sizes for the maximum packet sizes.
 .It Fn xdr_accepted_reply
 Used for encoding RPC reply messages.
 This routine is useful for users who wish to generate RPC-style



CVS commit: src/lib/libc/rpc

2016-02-15 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Feb 15 11:07:48 UTC 2016

Modified Files:
src/lib/libc/rpc: xdr_float.c

Log Message:
Avoid strict alias violation for VAX


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 src/lib/libc/rpc/xdr_float.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/rpc/xdr_float.c
diff -u src/lib/libc/rpc/xdr_float.c:1.40 src/lib/libc/rpc/xdr_float.c:1.41
--- src/lib/libc/rpc/xdr_float.c:1.40	Sun Aug 24 17:07:00 2014
+++ src/lib/libc/rpc/xdr_float.c	Mon Feb 15 11:07:48 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: xdr_float.c,v 1.40 2014/08/24 17:07:00 matt Exp $	*/
+/*	$NetBSD: xdr_float.c,v 1.41 2016/02/15 11:07:48 martin Exp $	*/
 
 /*
  * Copyright (c) 2010, Oracle America, Inc.
@@ -37,7 +37,7 @@
 static char *sccsid = "@(#)xdr_float.c 1.12 87/08/11 Copyr 1984 Sun Micro";
 static char *sccsid = "@(#)xdr_float.c	2.1 88/07/29 4.0 RPCSRC";
 #else
-__RCSID("$NetBSD: xdr_float.c,v 1.40 2014/08/24 17:07:00 matt Exp $");
+__RCSID("$NetBSD: xdr_float.c,v 1.41 2016/02/15 11:07:48 martin Exp $");
 #endif
 #endif
 
@@ -57,6 +57,7 @@ __RCSID("$NetBSD: xdr_float.c,v 1.40 201
 #include 
 
 #include 
+#include 
 
 #include 
 #include 
@@ -303,7 +304,7 @@ xdr_double(XDR *xdrs, double *dp)
 		vd.mantissa4 = (id.mantissa2 << 3);
 	doneit:
 		vd.sign = id.sign;
-		*dp = *((double *)(void *));
+		memcpy(dp, , sizeof(double));
 		return (TRUE);
 #endif
 



CVS commit: src/lib/libc/rpc

2015-11-13 Thread Matthias Scheler
Module Name:src
Committed By:   tron
Date:   Fri Nov 13 10:43:32 UTC 2015

Modified Files:
src/lib/libc/rpc: svc.c

Log Message:
Avoid broken state if realloc(3) fails.


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/lib/libc/rpc/svc.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/rpc/svc.c
diff -u src/lib/libc/rpc/svc.c:1.36 src/lib/libc/rpc/svc.c:1.37
--- src/lib/libc/rpc/svc.c:1.36	Sat Nov  7 17:34:33 2015
+++ src/lib/libc/rpc/svc.c	Fri Nov 13 10:43:32 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: svc.c,v 1.36 2015/11/07 17:34:33 christos Exp $	*/
+/*	$NetBSD: svc.c,v 1.37 2015/11/13 10:43:32 tron Exp $	*/
 
 /*
  * Copyright (c) 2010, Oracle America, Inc.
@@ -37,7 +37,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.36 2015/11/07 17:34:33 christos Exp $");
+__RCSID("$NetBSD: svc.c,v 1.37 2015/11/13 10:43:32 tron Exp $");
 #endif
 #endif
 
@@ -131,7 +131,7 @@ static bool_t
 xprt_alloc(int sock)
 {
 	int maxset;
-	char *newxports;
+	SVCXPRT **oldxports, **newxports;
 
 	if (++sock < 0)
 		return FALSE;
@@ -143,15 +143,16 @@ xprt_alloc(int sock)
 	if (__svc_xports != NULL && maxset <= __svc_maxxports)
 		return TRUE;
 
-	if (__svc_xports != NULL)
-		--__svc_xports;
-	newxports = realloc(__svc_xports, maxset * sizeof(SVCXPRT *));
+	oldxports = __svc_xports;
+	if (oldxports != NULL)
+		--oldxports;
+	newxports = realloc(oldxports, maxset * sizeof(SVCXPRT *));
 	if (newxports == NULL) {
 		warn("%s: out of memory", __func__);
 		return FALSE;
 	}
 
-	memset(newxports + __svc_maxxports * sizeof(SVCXPRT *), 0,
+	memset([__svc_maxxports], 0,
 	(maxset - __svc_maxxports) * sizeof(SVCXPRT *));
 
 	__svc_xports = (void *)newxports;



CVS commit: src/lib/libc/rpc

2015-11-13 Thread Matthias Scheler
Module Name:src
Committed By:   tron
Date:   Fri Nov 13 11:23:08 UTC 2015

Modified Files:
src/lib/libc/rpc: rpc_soc.c

Log Message:
Don't try to use listen(2) on a UDP socket which will always fail.
Previously this was not a problem because the return value of listen(2)
was ignored. With this fix amd(8) no longer fails to start with the
error message "cannot create rpc/udp service".

TL;DR: Make amd(8) work again


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/lib/libc/rpc/rpc_soc.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/rpc/rpc_soc.c
diff -u src/lib/libc/rpc/rpc_soc.c:1.21 src/lib/libc/rpc/rpc_soc.c:1.22
--- src/lib/libc/rpc/rpc_soc.c:1.21	Tue Nov 10 20:56:20 2015
+++ src/lib/libc/rpc/rpc_soc.c	Fri Nov 13 11:23:08 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: rpc_soc.c,v 1.21 2015/11/10 20:56:20 christos Exp $	*/
+/*	$NetBSD: rpc_soc.c,v 1.22 2015/11/13 11:23:08 tron Exp $	*/
 
 /*
  * Copyright (c) 2010, Oracle America, Inc.
@@ -45,7 +45,7 @@
 #if 0
 static char sccsid[] = "@(#)rpc_soc.c 1.41 89/05/02 Copyr 1988 Sun Micro";
 #else
-__RCSID("$NetBSD: rpc_soc.c,v 1.21 2015/11/10 20:56:20 christos Exp $");
+__RCSID("$NetBSD: rpc_soc.c,v 1.22 2015/11/13 11:23:08 tron Exp $");
 #endif
 #endif
 
@@ -255,8 +255,13 @@ svc_com_create(int fd, u_int sendsize, u
 	memset(, 0, sizeof sccsin);
 	sccsin.sin_family = AF_INET;
 	(void)bindresvport(fd, );
-	if (listen(fd, SOMAXCONN) == -1)
-		goto out;
+	if (strcmp(netid, "udp") != 0 && listen(fd, SOMAXCONN) == -1) {
+		(void) syslog(LOG_ERR,
+		   "svc%s_create: listen(2) failed: %s",
+		   netid, strerror(errno));
+		(void) freenetconfigent(nconf);
+ 		goto out;
+	}
 	svc = svc_tli_create(fd, nconf, NULL, sendsize, recvsize);
 	(void) freenetconfigent(nconf);
 	if (svc == NULL)



CVS commit: src/lib/libc/rpc

2015-11-13 Thread Matthias Scheler
Module Name:src
Committed By:   tron
Date:   Fri Nov 13 11:43:26 UTC 2015

Modified Files:
src/lib/libc/rpc: svc.c

Log Message:
Remove now unnecessary cast.


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/lib/libc/rpc/svc.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/rpc/svc.c
diff -u src/lib/libc/rpc/svc.c:1.37 src/lib/libc/rpc/svc.c:1.38
--- src/lib/libc/rpc/svc.c:1.37	Fri Nov 13 10:43:32 2015
+++ src/lib/libc/rpc/svc.c	Fri Nov 13 11:43:26 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: svc.c,v 1.37 2015/11/13 10:43:32 tron Exp $	*/
+/*	$NetBSD: svc.c,v 1.38 2015/11/13 11:43:26 tron Exp $	*/
 
 /*
  * Copyright (c) 2010, Oracle America, Inc.
@@ -37,7 +37,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.37 2015/11/13 10:43:32 tron Exp $");
+__RCSID("$NetBSD: svc.c,v 1.38 2015/11/13 11:43:26 tron Exp $");
 #endif
 #endif
 
@@ -155,7 +155,7 @@ xprt_alloc(int sock)
 	memset([__svc_maxxports], 0,
 	(maxset - __svc_maxxports) * sizeof(SVCXPRT *));
 
-	__svc_xports = (void *)newxports;
+	__svc_xports = newxports;
 	__svc_xports++;
 	__svc_maxxports = maxset;
 



CVS commit: src/lib/libc/rpc

2015-11-13 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Nov 13 15:23:17 UTC 2015

Modified Files:
src/lib/libc/rpc: rpc_soc.c

Log Message:
Generalize the test, compare on the protocol semantics instead of the name
since it could be udp6...


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/lib/libc/rpc/rpc_soc.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/rpc/rpc_soc.c
diff -u src/lib/libc/rpc/rpc_soc.c:1.22 src/lib/libc/rpc/rpc_soc.c:1.23
--- src/lib/libc/rpc/rpc_soc.c:1.22	Fri Nov 13 06:23:08 2015
+++ src/lib/libc/rpc/rpc_soc.c	Fri Nov 13 10:23:17 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: rpc_soc.c,v 1.22 2015/11/13 11:23:08 tron Exp $	*/
+/*	$NetBSD: rpc_soc.c,v 1.23 2015/11/13 15:23:17 christos Exp $	*/
 
 /*
  * Copyright (c) 2010, Oracle America, Inc.
@@ -45,7 +45,7 @@
 #if 0
 static char sccsid[] = "@(#)rpc_soc.c 1.41 89/05/02 Copyr 1988 Sun Micro";
 #else
-__RCSID("$NetBSD: rpc_soc.c,v 1.22 2015/11/13 11:23:08 tron Exp $");
+__RCSID("$NetBSD: rpc_soc.c,v 1.23 2015/11/13 15:23:17 christos Exp $");
 #endif
 #endif
 
@@ -255,13 +255,22 @@ svc_com_create(int fd, u_int sendsize, u
 	memset(, 0, sizeof sccsin);
 	sccsin.sin_family = AF_INET;
 	(void)bindresvport(fd, );
-	if (strcmp(netid, "udp") != 0 && listen(fd, SOMAXCONN) == -1) {
-		(void) syslog(LOG_ERR,
-		   "svc%s_create: listen(2) failed: %s",
-		   netid, strerror(errno));
-		(void) freenetconfigent(nconf);
- 		goto out;
+
+	switch (nconf->nc_semantics) {
+	case NC_TPI_COTS:
+	case NC_TPI_COTS_ORD:
+		if (listen(fd, SOMAXCONN) == -1) {
+			(void) syslog(LOG_ERR,
+			"svc%s_create: listen(2) failed: %s",
+			netid, strerror(errno));
+			(void) freenetconfigent(nconf);
+			goto out;
+		}
+		break;
+	default:
+		break;
 	}
+
 	svc = svc_tli_create(fd, nconf, NULL, sendsize, recvsize);
 	(void) freenetconfigent(nconf);
 	if (svc == NULL)



CVS commit: src/lib/libc/rpc

2015-11-13 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Nov 13 15:22:12 UTC 2015

Modified Files:
src/lib/libc/rpc: svc.c

Log Message:
Do proper accounting for the extra -1 slot. Perhaps this is too confusing
and it would be better to just access the array with [fd + 1] instead?


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 src/lib/libc/rpc/svc.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/rpc/svc.c
diff -u src/lib/libc/rpc/svc.c:1.38 src/lib/libc/rpc/svc.c:1.39
--- src/lib/libc/rpc/svc.c:1.38	Fri Nov 13 06:43:26 2015
+++ src/lib/libc/rpc/svc.c	Fri Nov 13 10:22:12 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: svc.c,v 1.38 2015/11/13 11:43:26 tron Exp $	*/
+/*	$NetBSD: svc.c,v 1.39 2015/11/13 15:22:12 christos Exp $	*/
 
 /*
  * Copyright (c) 2010, Oracle America, Inc.
@@ -37,7 +37,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.38 2015/11/13 11:43:26 tron Exp $");
+__RCSID("$NetBSD: svc.c,v 1.39 2015/11/13 15:22:12 christos Exp $");
 #endif
 #endif
 
@@ -130,34 +130,41 @@ static void __xprt_do_unregister(SVCXPRT
 static bool_t
 xprt_alloc(int sock)
 {
-	int maxset;
+	int oldmaxxports, newmaxxports;
 	SVCXPRT **oldxports, **newxports;
 
 	if (++sock < 0)
 		return FALSE;
 
-	maxset = svc_fdset_getsize(sock);
-	if (maxset == -1)
+	newmaxxports = svc_fdset_getsize(sock);
+	if (newmaxxports == -1)
 		return FALSE;
 
-	if (__svc_xports != NULL && maxset <= __svc_maxxports)
+	if (__svc_xports != NULL && newmaxxports < __svc_maxxports)
 		return TRUE;
 
 	oldxports = __svc_xports;
-	if (oldxports != NULL)
+	oldmaxxports = __svc_maxxports;
+	if (oldxports != NULL) {
+		/* revert saving [-1] slot */
 		--oldxports;
-	newxports = realloc(oldxports, maxset * sizeof(SVCXPRT *));
+		++oldmaxxports;
+	}
+
+	/* reserve an extra slot for [-1] */
+	newmaxxports++;
+	newxports = realloc(oldxports, newmaxxports * sizeof(SVCXPRT *));
 	if (newxports == NULL) {
 		warn("%s: out of memory", __func__);
 		return FALSE;
 	}
 
-	memset([__svc_maxxports], 0,
-	(maxset - __svc_maxxports) * sizeof(SVCXPRT *));
+	memset([oldmaxxports], 0,
+	(newmaxxports - oldmaxxports) * sizeof(SVCXPRT *));
 
-	__svc_xports = newxports;
-	__svc_xports++;
-	__svc_maxxports = maxset;
+	/* save one slot for [-1] */
+	__svc_xports = newxports + 1;
+	__svc_maxxports = newmaxxports - 1;
 
 	return TRUE;
 }



CVS commit: src/lib/libc/rpc

2015-11-10 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Nov 10 18:06:53 UTC 2015

Modified Files:
src/lib/libc/rpc: svc_run.c

Log Message:
CID 1338515: Make it clear that the pfd variable can't be NULL


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/lib/libc/rpc/svc_run.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/rpc/svc_run.c
diff -u src/lib/libc/rpc/svc_run.c:1.25 src/lib/libc/rpc/svc_run.c:1.26
--- src/lib/libc/rpc/svc_run.c:1.25	Sat Nov  7 18:09:20 2015
+++ src/lib/libc/rpc/svc_run.c	Tue Nov 10 13:06:53 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: svc_run.c,v 1.25 2015/11/07 23:09:20 christos Exp $	*/
+/*	$NetBSD: svc_run.c,v 1.26 2015/11/10 18:06:53 christos Exp $	*/
 
 /*
  * Copyright (c) 2010, Oracle America, Inc.
@@ -37,7 +37,7 @@
 static char *sccsid = "@(#)svc_run.c 1.1 87/10/13 Copyr 1984 Sun Micro";
 static char *sccsid = "@(#)svc_run.c	2.1 88/07/29 4.0 RPCSRC";
 #else
-__RCSID("$NetBSD: svc_run.c,v 1.25 2015/11/07 23:09:20 christos Exp $");
+__RCSID("$NetBSD: svc_run.c,v 1.26 2015/11/10 18:06:53 christos Exp $");
 #endif
 #endif
 
@@ -156,7 +156,7 @@ svc_run_poll(void)
 			goto out;
 		}
 
-		if (fdsize != svc_pollfd_getsize(0)) {
+		if (pdf == NULL || fdsize != svc_pollfd_getsize(0)) {
 			fdsize = svc_fdset_getsize(0);
 			free(pfd);
 			pfd = svc_pollfd_copy(svc_pollfd_get());



CVS commit: src/lib/libc/rpc

2015-11-10 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Nov 10 18:11:05 UTC 2015

Modified Files:
src/lib/libc/rpc: svc_fdset.c

Log Message:
CID 1338520: Check NULL
CID 1338521: Fix error (realloc returns different pointer)


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/lib/libc/rpc/svc_fdset.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/rpc/svc_fdset.c
diff -u src/lib/libc/rpc/svc_fdset.c:1.13 src/lib/libc/rpc/svc_fdset.c:1.14
--- src/lib/libc/rpc/svc_fdset.c:1.13	Tue Nov 10 13:08:05 2015
+++ src/lib/libc/rpc/svc_fdset.c	Tue Nov 10 13:11:05 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: svc_fdset.c,v 1.13 2015/11/10 18:08:05 christos Exp $	*/
+/*	$NetBSD: svc_fdset.c,v 1.14 2015/11/10 18:11:05 christos Exp $	*/
 
 /*-
  * Copyright (c) 2015 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: svc_fdset.c,v 1.13 2015/11/10 18:08:05 christos Exp $");
+__RCSID("$NetBSD: svc_fdset.c,v 1.14 2015/11/10 18:11:05 christos Exp $");
 
 
 #include "reentrant.h"
@@ -215,6 +215,7 @@ svc_pollfd_add(int fd, struct svc_fdset 
 	fds->fdused = fds->fdnum + 1;
 	DPRINTF("add fd=%d slot=%d fdused=%d", fd, fds->fdnum, fds->fdused);
 	fds->fdnum += FD_SETSIZE;
+	fds->fdp = pfd;
 	return fds;
 }
 
@@ -323,6 +324,8 @@ svc_fdset_zero(void)
 	DPRINTF("zero");
 
 	struct svc_fdset *fds = svc_fdset_alloc(0);
+	if (fds == NULL)
+		return;
 	memset(fds->fdset, 0, fds->fdsize);
 	fds->fdmax = -1;
 



CVS commit: src/lib/libc/rpc

2015-11-10 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Nov 10 18:01:16 UTC 2015

Modified Files:
src/lib/libc/rpc: rpc_soc.c

Log Message:
CID 1338513: Check listen(2) return


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/lib/libc/rpc/rpc_soc.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/rpc/rpc_soc.c
diff -u src/lib/libc/rpc/rpc_soc.c:1.19 src/lib/libc/rpc/rpc_soc.c:1.20
--- src/lib/libc/rpc/rpc_soc.c:1.19	Wed May 28 10:45:57 2014
+++ src/lib/libc/rpc/rpc_soc.c	Tue Nov 10 13:01:16 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: rpc_soc.c,v 1.19 2014/05/28 14:45:57 christos Exp $	*/
+/*	$NetBSD: rpc_soc.c,v 1.20 2015/11/10 18:01:16 christos Exp $	*/
 
 /*
  * Copyright (c) 2010, Oracle America, Inc.
@@ -45,7 +45,7 @@
 #if 0
 static char sccsid[] = "@(#)rpc_soc.c 1.41 89/05/02 Copyr 1988 Sun Micro";
 #else
-__RCSID("$NetBSD: rpc_soc.c,v 1.19 2014/05/28 14:45:57 christos Exp $");
+__RCSID("$NetBSD: rpc_soc.c,v 1.20 2015/11/10 18:01:16 christos Exp $");
 #endif
 #endif
 
@@ -255,17 +255,20 @@ svc_com_create(int fd, u_int sendsize, u
 	memset(, 0, sizeof sccsin);
 	sccsin.sin_family = AF_INET;
 	(void)bindresvport(fd, );
-	listen(fd, SOMAXCONN);
+	if (listen(fd, SOMAXCONN) == -1)
+		goto out;
 	svc = svc_tli_create(fd, nconf, NULL, sendsize, recvsize);
 	(void) freenetconfigent(nconf);
-	if (svc == NULL) {
-		if (madefd)
-			(void) close(fd);
-		return (NULL);
+	if (svc == NULL)
+		goto out;
 	}
 	port = (((struct sockaddr_in *)svc->xp_ltaddr.buf)->sin_port);
 	svc->xp_port = ntohs(port);
-	return (svc);
+	return svc;
+out:
+	if (madefd)
+		(void) close(fd);
+	return NULL;
 }
 
 SVCXPRT *



CVS commit: src/lib/libc/rpc

2015-11-10 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Nov 10 18:08:05 UTC 2015

Modified Files:
src/lib/libc/rpc: svc_fdset.c

Log Message:
CID 1338517: Check negative returns


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/lib/libc/rpc/svc_fdset.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/rpc/svc_fdset.c
diff -u src/lib/libc/rpc/svc_fdset.c:1.12 src/lib/libc/rpc/svc_fdset.c:1.13
--- src/lib/libc/rpc/svc_fdset.c:1.12	Sun Nov  8 14:30:53 2015
+++ src/lib/libc/rpc/svc_fdset.c	Tue Nov 10 13:08:05 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: svc_fdset.c,v 1.12 2015/11/08 19:30:53 christos Exp $	*/
+/*	$NetBSD: svc_fdset.c,v 1.13 2015/11/10 18:08:05 christos Exp $	*/
 
 /*-
  * Copyright (c) 2015 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: svc_fdset.c,v 1.12 2015/11/08 19:30:53 christos Exp $");
+__RCSID("$NetBSD: svc_fdset.c,v 1.13 2015/11/10 18:08:05 christos Exp $");
 
 
 #include "reentrant.h"
@@ -434,6 +434,8 @@ struct pollfd *
 svc_pollfd_copy(const struct pollfd *orig)
 {
 	int size = svc_fdset_getsize(0);
+	if (size == -1)
+		return NULL;
 	struct pollfd *copy = calloc(size, sizeof(*orig));
 	if (copy == NULL)
 		return NULL;



CVS commit: src/lib/libc/rpc

2015-11-10 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Nov 10 20:56:20 UTC 2015

Modified Files:
src/lib/libc/rpc: rpc_soc.c svc_fdset.c svc_run.c svc_vc.c

Log Message:
fix compilation/lint


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/lib/libc/rpc/rpc_soc.c
cvs rdiff -u -r1.14 -r1.15 src/lib/libc/rpc/svc_fdset.c
cvs rdiff -u -r1.26 -r1.27 src/lib/libc/rpc/svc_run.c
cvs rdiff -u -r1.33 -r1.34 src/lib/libc/rpc/svc_vc.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/rpc/rpc_soc.c
diff -u src/lib/libc/rpc/rpc_soc.c:1.20 src/lib/libc/rpc/rpc_soc.c:1.21
--- src/lib/libc/rpc/rpc_soc.c:1.20	Tue Nov 10 13:01:16 2015
+++ src/lib/libc/rpc/rpc_soc.c	Tue Nov 10 15:56:20 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: rpc_soc.c,v 1.20 2015/11/10 18:01:16 christos Exp $	*/
+/*	$NetBSD: rpc_soc.c,v 1.21 2015/11/10 20:56:20 christos Exp $	*/
 
 /*
  * Copyright (c) 2010, Oracle America, Inc.
@@ -45,7 +45,7 @@
 #if 0
 static char sccsid[] = "@(#)rpc_soc.c 1.41 89/05/02 Copyr 1988 Sun Micro";
 #else
-__RCSID("$NetBSD: rpc_soc.c,v 1.20 2015/11/10 18:01:16 christos Exp $");
+__RCSID("$NetBSD: rpc_soc.c,v 1.21 2015/11/10 20:56:20 christos Exp $");
 #endif
 #endif
 
@@ -261,7 +261,6 @@ svc_com_create(int fd, u_int sendsize, u
 	(void) freenetconfigent(nconf);
 	if (svc == NULL)
 		goto out;
-	}
 	port = (((struct sockaddr_in *)svc->xp_ltaddr.buf)->sin_port);
 	svc->xp_port = ntohs(port);
 	return svc;

Index: src/lib/libc/rpc/svc_fdset.c
diff -u src/lib/libc/rpc/svc_fdset.c:1.14 src/lib/libc/rpc/svc_fdset.c:1.15
--- src/lib/libc/rpc/svc_fdset.c:1.14	Tue Nov 10 13:11:05 2015
+++ src/lib/libc/rpc/svc_fdset.c	Tue Nov 10 15:56:20 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: svc_fdset.c,v 1.14 2015/11/10 18:11:05 christos Exp $	*/
+/*	$NetBSD: svc_fdset.c,v 1.15 2015/11/10 20:56:20 christos Exp $	*/
 
 /*-
  * Copyright (c) 2015 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: svc_fdset.c,v 1.14 2015/11/10 18:11:05 christos Exp $");
+__RCSID("$NetBSD: svc_fdset.c,v 1.15 2015/11/10 20:56:20 christos Exp $");
 
 
 #include "reentrant.h"
@@ -146,7 +146,7 @@ svc_fdset_sanitize(struct svc_fdset *fds
 #ifdef _LIBC
 	/* Compat update */
 	if (fds == &__svc_fdset) {
-		svc_fdset = *(__fd_set_256 *)__svc_fdset.fdset;
+		svc_fdset = *(__fd_set_256 *)(void *)__svc_fdset.fdset;
 		svc_maxfd = __svc_fdset.fdmax;
 	}
 #endif

Index: src/lib/libc/rpc/svc_run.c
diff -u src/lib/libc/rpc/svc_run.c:1.26 src/lib/libc/rpc/svc_run.c:1.27
--- src/lib/libc/rpc/svc_run.c:1.26	Tue Nov 10 13:06:53 2015
+++ src/lib/libc/rpc/svc_run.c	Tue Nov 10 15:56:20 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: svc_run.c,v 1.26 2015/11/10 18:06:53 christos Exp $	*/
+/*	$NetBSD: svc_run.c,v 1.27 2015/11/10 20:56:20 christos Exp $	*/
 
 /*
  * Copyright (c) 2010, Oracle America, Inc.
@@ -37,7 +37,7 @@
 static char *sccsid = "@(#)svc_run.c 1.1 87/10/13 Copyr 1984 Sun Micro";
 static char *sccsid = "@(#)svc_run.c	2.1 88/07/29 4.0 RPCSRC";
 #else
-__RCSID("$NetBSD: svc_run.c,v 1.26 2015/11/10 18:06:53 christos Exp $");
+__RCSID("$NetBSD: svc_run.c,v 1.27 2015/11/10 20:56:20 christos Exp $");
 #endif
 #endif
 
@@ -156,7 +156,7 @@ svc_run_poll(void)
 			goto out;
 		}
 
-		if (pdf == NULL || fdsize != svc_pollfd_getsize(0)) {
+		if (pfd == NULL || fdsize != svc_pollfd_getsize(0)) {
 			fdsize = svc_fdset_getsize(0);
 			free(pfd);
 			pfd = svc_pollfd_copy(svc_pollfd_get());
@@ -169,7 +169,7 @@ svc_run_poll(void)
 
 		rwlock_unlock(_fd_lock);
 
-		switch ((i = poll(pfd, *maxfd, 30 * 1000))) {
+		switch ((i = poll(pfd, (size_t)*maxfd, 30 * 1000))) {
 		case -1:
 #ifndef RUMP_RPC		
 			if ((errno == EINTR || errno == EBADF) && probs < 100) {

Index: src/lib/libc/rpc/svc_vc.c
diff -u src/lib/libc/rpc/svc_vc.c:1.33 src/lib/libc/rpc/svc_vc.c:1.34
--- src/lib/libc/rpc/svc_vc.c:1.33	Sat Nov  7 18:09:20 2015
+++ src/lib/libc/rpc/svc_vc.c	Tue Nov 10 15:56:20 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: svc_vc.c,v 1.33 2015/11/07 23:09:20 christos Exp $	*/
+/*	$NetBSD: svc_vc.c,v 1.34 2015/11/10 20:56:20 christos Exp $	*/
 
 /*
  * Copyright (c) 2010, Oracle America, Inc.
@@ -37,7 +37,7 @@
 static char *sccsid = "@(#)svc_tcp.c 1.21 87/08/11 Copyr 1984 Sun Micro";
 static char *sccsid = "@(#)svc_tcp.c	2.2 88/08/01 4.0 RPCSRC";
 #else
-__RCSID("$NetBSD: svc_vc.c,v 1.33 2015/11/07 23:09:20 christos Exp $");
+__RCSID("$NetBSD: svc_vc.c,v 1.34 2015/11/10 20:56:20 christos Exp $");
 #endif
 #endif
 
@@ -756,6 +756,7 @@ svc_vc_rendezvous_ops(SVCXPRT *xprt)
  * cleaned. If timeout is 0, the least active connection is picked.
  */
 bool_t
+/*ARGSUSED1*/
 __svc_clean_idle(fd_set *fds __unused, int timeout, bool_t cleanblock)
 {
 	int i, ncleaned, *fdmax;



CVS commit: src/lib/libc/rpc

2015-11-08 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Nov  8 19:30:53 UTC 2015

Modified Files:
src/lib/libc/rpc: svc_fdset.c

Log Message:
Add debugging for pollfd


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/lib/libc/rpc/svc_fdset.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/rpc/svc_fdset.c
diff -u src/lib/libc/rpc/svc_fdset.c:1.11 src/lib/libc/rpc/svc_fdset.c:1.12
--- src/lib/libc/rpc/svc_fdset.c:1.11	Sat Nov  7 21:46:53 2015
+++ src/lib/libc/rpc/svc_fdset.c	Sun Nov  8 14:30:53 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: svc_fdset.c,v 1.11 2015/11/08 02:46:53 christos Exp $	*/
+/*	$NetBSD: svc_fdset.c,v 1.12 2015/11/08 19:30:53 christos Exp $	*/
 
 /*-
  * Copyright (c) 2015 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: svc_fdset.c,v 1.11 2015/11/08 02:46:53 christos Exp $");
+__RCSID("$NetBSD: svc_fdset.c,v 1.12 2015/11/08 19:30:53 christos Exp $");
 
 
 #include "reentrant.h"
@@ -97,13 +97,22 @@ svc_fdset_print(const char *func, size_t
 	svc_header(func, line, fmt, ap);
 	va_end(ap);
 
-	fprintf(stderr, "%p[%d] <", fds->fdset, fds->fdmax);
+	fprintf(stderr, "%p[%d] fd_set<", fds->fdset, fds->fdmax);
 	for (int i = 0; i <= fds->fdmax; i++) {
 		if (!FD_ISSET(i, fds->fdset))
 			continue;
 		fprintf(stderr, "%s%d", did, i);
 		did = ", ";
 	}
+	did = "";
+	fprintf(stderr, "> poll<");
+	for (int i = 0; i < fds->fdused; i++) {
+		int fd = fds->fdp[i].fd;
+		if (fd == -1)
+			continue;
+		fprintf(stderr, "%s%d", did, fd);
+		did = ", ";
+	}
 	fprintf(stderr, ">\n");
 }
 
@@ -167,6 +176,9 @@ svc_pollfd_init(struct pollfd *pfd, int 
 static struct pollfd *
 svc_pollfd_alloc(struct svc_fdset *fds)
 {
+	if (fds->fdp != NULL)
+		return fds->fdp;
+		
 	fds->fdnum = FD_SETSIZE;
 	fds->fdp = calloc(fds->fdnum, sizeof(*fds->fdp));
 	if (fds->fdp == NULL)
@@ -186,8 +198,10 @@ svc_pollfd_add(int fd, struct svc_fdset 
 
 	for (int i = 0; i < fds->fdnum; i++)
 		if (pfd[i].fd == -1) {
-			if (i > fds->fdused)
+			if (i >= fds->fdused)
 fds->fdused = i + 1;
+			DPRINTF("add fd=%d slot=%d fdused=%d",
+			fd, i, fds->fdused);
 			pfd[i].fd = fd;
 			return fds;
 		}
@@ -199,6 +213,7 @@ svc_pollfd_add(int fd, struct svc_fdset 
 	svc_pollfd_init(pfd + fds->fdnum, FD_SETSIZE);
 	pfd[fds->fdnum].fd = fd;
 	fds->fdused = fds->fdnum + 1;
+	DPRINTF("add fd=%d slot=%d fdused=%d", fd, fds->fdnum, fds->fdused);
 	fds->fdnum += FD_SETSIZE;
 	return fds;
 }
@@ -216,6 +231,7 @@ svc_pollfd_del(int fd, struct svc_fdset 
 			continue;
 
 		pfd[i].fd = -1;
+		DPRINTF("del fd=%d slot=%d", fd, fds->fdused);
 		if (i != fds->fdused - 1)
 			return fds;
 
@@ -223,9 +239,12 @@ svc_pollfd_del(int fd, struct svc_fdset 
 			if (pfd[i].fd != -1) 
 break;
 		while (--i >= 0);
+
 		fds->fdused = i + 1;
+		DPRINTF("del fd=%d fdused=%d", fd, fds->fdused);
 		return fds;
 	}
+	DPRINTF("del fd=%d not found", fd);
 	return NULL;
 }
 
@@ -324,10 +343,11 @@ svc_fdset_set(int fd)
 	if (fd > fds->fdmax)
 		fds->fdmax = fd;
 
+	int rv = svc_pollfd_add(fd, fds) ? 0 : -1;
 	DPRINTF_FDSET(fds, "%d", fd);
 
 	svc_fdset_sanitize(fds);
-	return svc_pollfd_add(fd, fds) ? 0 : -1;
+	return rv;
 }
 
 int
@@ -352,10 +372,12 @@ svc_fdset_clr(int fd)
 		return -1;
 
 	FD_CLR(fd, fds->fdset);
+
+	int rv = svc_pollfd_del(fd, fds) ? 0 : -1;
 	DPRINTF_FDSET(fds, "%d", fd);
 
 	svc_fdset_sanitize(fds);
-	return svc_pollfd_del(fd, fds) ? 0 : -1;
+	return rv;
 }
 
 fd_set *



CVS commit: src/lib/libc/rpc

2015-11-07 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Nov  7 14:21:32 UTC 2015

Modified Files:
src/lib/libc/rpc: rpc_commondata.c

Log Message:
don't compile with SVC_LEGACY


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/lib/libc/rpc/rpc_commondata.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/rpc/rpc_commondata.c
diff -u src/lib/libc/rpc/rpc_commondata.c:1.12 src/lib/libc/rpc/rpc_commondata.c:1.13
--- src/lib/libc/rpc/rpc_commondata.c:1.12	Fri Nov  6 19:42:04 2015
+++ src/lib/libc/rpc/rpc_commondata.c	Sat Nov  7 09:21:32 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: rpc_commondata.c,v 1.12 2015/11/07 00:42:04 christos Exp $	*/
+/*	$NetBSD: rpc_commondata.c,v 1.13 2015/11/07 14:21:32 christos Exp $	*/
 
 /*
  * Copyright (c) 2010, Oracle America, Inc.
@@ -31,14 +31,12 @@
  *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#define SVC_LEGACY
-
 #include 
 #if defined(LIBC_SCCS) && !defined(lint)
 #if 0
 static char *sccsid = "@(#)rpc_commondata.c	2.1 88/07/29 4.0 RPCSRC";
 #else
-__RCSID("$NetBSD: rpc_commondata.c,v 1.12 2015/11/07 00:42:04 christos Exp $");
+__RCSID("$NetBSD: rpc_commondata.c,v 1.13 2015/11/07 14:21:32 christos Exp $");
 #endif
 #endif
 



CVS commit: src/lib/libc/rpc

2015-11-07 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Nov  7 20:24:00 UTC 2015

Modified Files:
src/lib/libc/rpc: svc_fdset.c

Log Message:
spell reserved.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/lib/libc/rpc/svc_fdset.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/rpc/svc_fdset.c
diff -u src/lib/libc/rpc/svc_fdset.c:1.7 src/lib/libc/rpc/svc_fdset.c:1.8
--- src/lib/libc/rpc/svc_fdset.c:1.7	Sat Nov  7 11:58:24 2015
+++ src/lib/libc/rpc/svc_fdset.c	Sat Nov  7 15:24:00 2015
@@ -1,8 +1,8 @@
-/*	$NetBSD: svc_fdset.c,v 1.7 2015/11/07 16:58:24 christos Exp $	*/
+/*	$NetBSD: svc_fdset.c,v 1.8 2015/11/07 20:24:00 christos Exp $	*/
 
 /*-
  * Copyright (c) 2015 The NetBSD Foundation, Inc.
- * All rights resefdsed.
+ * All rights reserved.
  *
  * This code is derived from software contributed to The NetBSD Foundation
  * by Christos Zoulas.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: svc_fdset.c,v 1.7 2015/11/07 16:58:24 christos Exp $");
+__RCSID("$NetBSD: svc_fdset.c,v 1.8 2015/11/07 20:24:00 christos Exp $");
 
 
 #include "reentrant.h"



CVS commit: src/lib/libc/rpc

2015-11-07 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Nov  7 17:34:33 UTC 2015

Modified Files:
src/lib/libc/rpc: svc.c svc_run.c svc_vc.c

Log Message:
check for errors and recover instead of core-dumping.


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/lib/libc/rpc/svc.c
cvs rdiff -u -r1.23 -r1.24 src/lib/libc/rpc/svc_run.c
cvs rdiff -u -r1.31 -r1.32 src/lib/libc/rpc/svc_vc.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/rpc/svc.c
diff -u src/lib/libc/rpc/svc.c:1.35 src/lib/libc/rpc/svc.c:1.36
--- src/lib/libc/rpc/svc.c:1.35	Fri Nov  6 14:34:13 2015
+++ src/lib/libc/rpc/svc.c	Sat Nov  7 12:34:33 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: svc.c,v 1.35 2015/11/06 19:34:13 christos Exp $	*/
+/*	$NetBSD: svc.c,v 1.36 2015/11/07 17:34:33 christos Exp $	*/
 
 /*
  * Copyright (c) 2010, Oracle America, Inc.
@@ -37,7 +37,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.35 2015/11/06 19:34:13 christos Exp $");
+__RCSID("$NetBSD: svc.c,v 1.36 2015/11/07 17:34:33 christos Exp $");
 #endif
 #endif
 
@@ -179,7 +179,8 @@ xprt_register(SVCXPRT *xprt)
 
 	__svc_xports[sock] = xprt;
 	if (sock != -1) {
-		svc_fdset_set(sock);
+		if (svc_fdset_set(sock) == -1)
+			return FALSE;
 	}
 	rwlock_unlock(_fd_lock);
 	return (TRUE);
@@ -222,7 +223,7 @@ __xprt_do_unregister(SVCXPRT *xprt, bool
 	if (sock == -1)
 		goto out;
 	fdmax = svc_fdset_getmax();
-	if (sock < *fdmax)
+	if (fdmax == NULL || sock < *fdmax)
 		goto clr;
 
 	for ((*fdmax)--; *fdmax >= 0; (*fdmax)--)
@@ -634,6 +635,8 @@ void
 svc_getreq(int rdfds)
 {
 	fd_set *readfds = svc_fdset_copy(NULL);
+	if (readfds == NULL)
+		return;
 
 	readfds->fds_bits[0] = (unsigned int)rdfds;
 	svc_getreqset(readfds);
@@ -771,7 +774,7 @@ svc_getreq_poll(struct pollfd *pfdp, int
 			 *	via someone select()ing from svc_fdset or
 			 *	pollts()ing from svc_pollset[].  Thus it's safe
 			 *	to handle the POLLNVAL event by simply turning
-			 *	the corresponding bit off in svc_fdset.  The
+			 *	the corresponding bit off in the fdset.  The
 			 *	svc_pollset[] array is derived from svc_fdset
 			 *	and so will also be updated eventually.
 			 *

Index: src/lib/libc/rpc/svc_run.c
diff -u src/lib/libc/rpc/svc_run.c:1.23 src/lib/libc/rpc/svc_run.c:1.24
--- src/lib/libc/rpc/svc_run.c:1.23	Fri Nov  6 14:34:13 2015
+++ src/lib/libc/rpc/svc_run.c	Sat Nov  7 12:34:33 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: svc_run.c,v 1.23 2015/11/06 19:34:13 christos Exp $	*/
+/*	$NetBSD: svc_run.c,v 1.24 2015/11/07 17:34:33 christos Exp $	*/
 
 /*
  * Copyright (c) 2010, Oracle America, Inc.
@@ -37,7 +37,7 @@
 static char *sccsid = "@(#)svc_run.c 1.1 87/10/13 Copyr 1984 Sun Micro";
 static char *sccsid = "@(#)svc_run.c	2.1 88/07/29 4.0 RPCSRC";
 #else
-__RCSID("$NetBSD: svc_run.c,v 1.23 2015/11/06 19:34:13 christos Exp $");
+__RCSID("$NetBSD: svc_run.c,v 1.24 2015/11/07 17:34:33 christos Exp $");
 #endif
 #endif
 
@@ -69,7 +69,7 @@ svc_run(void)
 {
 	fd_set *readfds, *cleanfds;
 	struct timeval timeout;
-	int maxfd, fdsize;
+	int *maxfd, fdsize;
 #ifndef RUMP_RPC		
 	int probs = 0;
 #endif
@@ -92,9 +92,13 @@ svc_run(void)
 			free(cleanfds);
 			cleanfds = svc_fdset_copy(svc_fdset_get());
 		}
-		maxfd = *svc_fdset_getmax();
+		maxfd = svc_fdset_getmax();
+		if (maxfd == NULL) {
+			warn("can't get maxfd");
+			continue;
+		}
 		rwlock_unlock(_fd_lock);
-		switch (select(maxfd + 1, readfds, NULL, NULL, )) {
+		switch (select(*maxfd + 1, readfds, NULL, NULL, )) {
 		case -1:
 #ifndef RUMP_RPC		
 			if ((errno == EINTR || errno == EBADF) && probs < 100) {
@@ -108,10 +112,12 @@ svc_run(void)
 			warn("%s: select failed", __func__);
 			goto out;
 		case 0:
-			__svc_clean_idle(cleanfds, 30, FALSE);
+			if (cleanfds)
+__svc_clean_idle(cleanfds, 30, FALSE);
 			continue;
 		default:
-			svc_getreqset2(readfds, fdsize);
+			if (readfds)
+svc_getreqset2(readfds, fdsize);
 #ifndef RUMP_RPC
 			probs = 0;
 #endif

Index: src/lib/libc/rpc/svc_vc.c
diff -u src/lib/libc/rpc/svc_vc.c:1.31 src/lib/libc/rpc/svc_vc.c:1.32
--- src/lib/libc/rpc/svc_vc.c:1.31	Fri Nov  6 14:34:13 2015
+++ src/lib/libc/rpc/svc_vc.c	Sat Nov  7 12:34:33 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: svc_vc.c,v 1.31 2015/11/06 19:34:13 christos Exp $	*/
+/*	$NetBSD: svc_vc.c,v 1.32 2015/11/07 17:34:33 christos Exp $	*/
 
 /*
  * Copyright (c) 2010, Oracle America, Inc.
@@ -37,7 +37,7 @@
 static char *sccsid = "@(#)svc_tcp.c 1.21 87/08/11 Copyr 1984 Sun Micro";
 static char *sccsid = "@(#)svc_tcp.c	2.2 88/08/01 4.0 RPCSRC";
 #else
-__RCSID("$NetBSD: svc_vc.c,v 1.31 2015/11/06 19:34:13 christos Exp $");
+__RCSID("$NetBSD: svc_vc.c,v 1.32 2015/11/07 17:34:33 christos Exp $");
 #endif
 #endif
 
@@ -329,7 +329,9 @@ again:
 		 */
 		if (errno == EMFILE || errno == ENFILE) {
 			fd_set *cleanfds = 

CVS commit: src/lib/libc/rpc

2015-11-07 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Nov  7 23:17:09 UTC 2015

Modified Files:
src/lib/libc/rpc: svc_fdset.c

Log Message:
initialize revents too.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/lib/libc/rpc/svc_fdset.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/rpc/svc_fdset.c
diff -u src/lib/libc/rpc/svc_fdset.c:1.9 src/lib/libc/rpc/svc_fdset.c:1.10
--- src/lib/libc/rpc/svc_fdset.c:1.9	Sat Nov  7 18:09:20 2015
+++ src/lib/libc/rpc/svc_fdset.c	Sat Nov  7 18:17:09 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: svc_fdset.c,v 1.9 2015/11/07 23:09:20 christos Exp $	*/
+/*	$NetBSD: svc_fdset.c,v 1.10 2015/11/07 23:17:09 christos Exp $	*/
 
 /*-
  * Copyright (c) 2015 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: svc_fdset.c,v 1.9 2015/11/07 23:09:20 christos Exp $");
+__RCSID("$NetBSD: svc_fdset.c,v 1.10 2015/11/07 23:17:09 christos Exp $");
 
 
 #include "reentrant.h"
@@ -156,6 +156,7 @@ svc_pollfd_init(struct pollfd *pfd, int 
 	for (int i = 0; i < nfd; i++) {
 		pfd[i].fd = -1;
 		pfd[i].events = POLLIN | POLLPRI | POLLRDNORM | POLLRDBAND;
+		pfd[i].revents = 0;
 	}
 }
 



CVS commit: src/lib/libc/rpc

2015-11-07 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Nov  7 23:09:20 UTC 2015

Modified Files:
src/lib/libc/rpc: rpc_internal.h svc_fdset.c svc_run.c svc_vc.c

Log Message:
PR/50408: Pedro Giffuni: Provide a way for rpc to use poll(2) instead of
select(2), and the linux svc_pollfd and svc_maxpollfd members. Our select(2)
implementation does not suffer from the FD_SETSIZE limitation so this is
not turned on by default.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/lib/libc/rpc/rpc_internal.h
cvs rdiff -u -r1.8 -r1.9 src/lib/libc/rpc/svc_fdset.c
cvs rdiff -u -r1.24 -r1.25 src/lib/libc/rpc/svc_run.c
cvs rdiff -u -r1.32 -r1.33 src/lib/libc/rpc/svc_vc.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/rpc/rpc_internal.h
diff -u src/lib/libc/rpc/rpc_internal.h:1.7 src/lib/libc/rpc/rpc_internal.h:1.8
--- src/lib/libc/rpc/rpc_internal.h:1.7	Tue May  7 17:08:45 2013
+++ src/lib/libc/rpc/rpc_internal.h	Sat Nov  7 18:09:20 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: rpc_internal.h,v 1.7 2013/05/07 21:08:45 christos Exp $	*/
+/*	$NetBSD: rpc_internal.h,v 1.8 2015/11/07 23:09:20 christos Exp $	*/
 
 /*-
  * Copyright (c) 2004 The NetBSD Foundation, Inc.
@@ -63,5 +63,6 @@ u_int32_t __rpc_getxid(void);
 
 extern SVCXPRT **__svc_xports;
 extern int __svc_maxrec;
+extern int __svc_flags;
 
 int __clnt_sigfillset(sigset_t *);

Index: src/lib/libc/rpc/svc_fdset.c
diff -u src/lib/libc/rpc/svc_fdset.c:1.8 src/lib/libc/rpc/svc_fdset.c:1.9
--- src/lib/libc/rpc/svc_fdset.c:1.8	Sat Nov  7 15:24:00 2015
+++ src/lib/libc/rpc/svc_fdset.c	Sat Nov  7 18:09:20 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: svc_fdset.c,v 1.8 2015/11/07 20:24:00 christos Exp $	*/
+/*	$NetBSD: svc_fdset.c,v 1.9 2015/11/07 23:09:20 christos Exp $	*/
 
 /*-
  * Copyright (c) 2015 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: svc_fdset.c,v 1.8 2015/11/07 20:24:00 christos Exp $");
+__RCSID("$NetBSD: svc_fdset.c,v 1.9 2015/11/07 23:09:20 christos Exp $");
 
 
 #include "reentrant.h"
@@ -47,6 +47,7 @@ __RCSID("$NetBSD: svc_fdset.c,v 1.8 2015
 #endif
 #include 
 #include 
+#include 
 
 #include "svc_fdset.h"
 
@@ -54,11 +55,17 @@ __RCSID("$NetBSD: svc_fdset.c,v 1.8 2015
 #undef svc_maxfd
 extern __fd_set_256 svc_fdset;
 extern int svc_maxfd;
+int __svc_flags;
 
 struct svc_fdset {
+	/* select */
 	fd_set *fdset;
 	int	fdmax;
 	int	fdsize;
+	/* poll */
+	struct pollfd *fdp;
+	int	fdnum;
+	int	fdused;
 };
 
 /* The single threaded, one global fd_set version */
@@ -138,10 +145,85 @@ svc_fdset_free(void *v)
 	struct svc_fdset *fds = v;
 	DPRINTF_FDSET(fds, "free");
 
+	free(fds->fdp);
 	free(fds->fdset);
 	free(fds);
 }
 
+static void
+svc_pollfd_init(struct pollfd *pfd, int nfd)
+{
+	for (int i = 0; i < nfd; i++) {
+		pfd[i].fd = -1;
+		pfd[i].events = POLLIN | POLLPRI | POLLRDNORM | POLLRDBAND;
+	}
+}
+
+static struct pollfd *
+svc_pollfd_alloc(struct svc_fdset *fds)
+{
+	fds->fdnum = FD_SETSIZE;
+	fds->fdp = calloc(fds->fdnum, sizeof(*fds->fdp));
+	if (fds->fdp == NULL)
+		return NULL;
+	svc_pollfd_init(fds->fdp, fds->fdnum);
+	return fds->fdp;
+}
+
+
+static struct svc_fdset *
+svc_pollfd_add(int fd, struct svc_fdset *fds)
+{
+	struct pollfd *pfd;
+
+	if ((pfd = svc_pollfd_alloc(fds)) == NULL)
+		return NULL;
+
+	for (int i = 0; i < fds->fdnum; i++)
+		if (pfd[i].fd == -1) {
+			if (i > fds->fdused)
+fds->fdused = i + 1;
+			pfd[i].fd = fd;
+			return fds;
+		}
+
+	pfd = realloc(fds->fdp, (fds->fdnum + FD_SETSIZE) * sizeof(*fds->fdp));
+	if (pfd == NULL)
+		return NULL;
+
+	svc_pollfd_init(pfd + fds->fdnum, FD_SETSIZE);
+	pfd[fds->fdnum].fd = fd;
+	fds->fdused = fds->fdnum + 1;
+	fds->fdnum += FD_SETSIZE;
+	return fds;
+}
+
+static struct svc_fdset *
+svc_pollfd_del(int fd, struct svc_fdset *fds)
+{
+	struct pollfd *pfd;
+
+	if ((pfd = svc_pollfd_alloc(fds)) == NULL)
+		return NULL;
+
+	for (int i = 0; i < fds->fdnum; i++) {
+		if (pfd[i].fd != fd)
+			continue;
+
+		pfd[i].fd = -1;
+		if (i != fds->fdused - 1)
+			return fds;
+
+		do
+			if (pfd[i].fd != -1) 
+break;
+		while (--i >= 0);
+		fds->fdused = i + 1;
+		return fds;
+	}
+	return NULL;
+}
+
 static struct svc_fdset *
 svc_fdset_resize(int fd, struct svc_fdset *fds)
 {
@@ -206,6 +288,7 @@ void
 svc_fdset_init(int flags)
 {
 	DPRINTF("%x", flags);
+	__svc_flags = flags;
 	if ((flags & SVC_FDSET_MT) && fdsetkey == -2)
 		fdsetkey = -1;
 }
@@ -214,9 +297,14 @@ void
 svc_fdset_zero(void)
 {
 	DPRINTF("zero");
+
 	struct svc_fdset *fds = svc_fdset_alloc(0);
 	memset(fds->fdset, 0, fds->fdsize);
 	fds->fdmax = -1;
+
+	free(fds->fdp);
+	fds->fdp = NULL;
+	fds->fdnum = fds->fdused = 0;
 }
 
 int
@@ -234,7 +322,7 @@ svc_fdset_set(int fd)
 	DPRINTF_FDSET(fds, "%d", fd);
 
 	svc_fdset_sanitize(fds);
-	return 0;
+	return svc_pollfd_add(fd, fds) ? 0 : -1;
 }
 
 int
@@ -262,7 +350,7 @@ svc_fdset_clr(int fd)
 	DPRINTF_FDSET(fds, "%d", fd);
 
 	

CVS commit: src/lib/libc/rpc

2015-11-07 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Nov  8 02:46:53 UTC 2015

Modified Files:
src/lib/libc/rpc: rpc_commondata.c svc_fdset.c svc_fdset.h

Log Message:
Only do the compat cruft if we are compiling libc.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/lib/libc/rpc/rpc_commondata.c
cvs rdiff -u -r1.10 -r1.11 src/lib/libc/rpc/svc_fdset.c
cvs rdiff -u -r1.3 -r1.4 src/lib/libc/rpc/svc_fdset.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/rpc/rpc_commondata.c
diff -u src/lib/libc/rpc/rpc_commondata.c:1.13 src/lib/libc/rpc/rpc_commondata.c:1.14
--- src/lib/libc/rpc/rpc_commondata.c:1.13	Sat Nov  7 09:21:32 2015
+++ src/lib/libc/rpc/rpc_commondata.c	Sat Nov  7 21:46:53 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: rpc_commondata.c,v 1.13 2015/11/07 14:21:32 christos Exp $	*/
+/*	$NetBSD: rpc_commondata.c,v 1.14 2015/11/08 02:46:53 christos Exp $	*/
 
 /*
  * Copyright (c) 2010, Oracle America, Inc.
@@ -36,7 +36,7 @@
 #if 0
 static char *sccsid = "@(#)rpc_commondata.c	2.1 88/07/29 4.0 RPCSRC";
 #else
-__RCSID("$NetBSD: rpc_commondata.c,v 1.13 2015/11/07 14:21:32 christos Exp $");
+__RCSID("$NetBSD: rpc_commondata.c,v 1.14 2015/11/08 02:46:53 christos Exp $");
 #endif
 #endif
 
@@ -48,10 +48,12 @@ __RCSID("$NetBSD: rpc_commondata.c,v 1.1
  * by public interfaces 
  */
 struct opaque_auth _null_auth;
+#ifdef _LIBC
 #undef svc_fdset
 __fd_set_256 svc_fdset;
 #undef svc_maxfd
 int svc_maxfd = -1;
+#endif
 #ifndef _REENTRANT
 #undef rpc_createerr
 struct rpc_createerr rpc_createerr;

Index: src/lib/libc/rpc/svc_fdset.c
diff -u src/lib/libc/rpc/svc_fdset.c:1.10 src/lib/libc/rpc/svc_fdset.c:1.11
--- src/lib/libc/rpc/svc_fdset.c:1.10	Sat Nov  7 18:17:09 2015
+++ src/lib/libc/rpc/svc_fdset.c	Sat Nov  7 21:46:53 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: svc_fdset.c,v 1.10 2015/11/07 23:17:09 christos Exp $	*/
+/*	$NetBSD: svc_fdset.c,v 1.11 2015/11/08 02:46:53 christos Exp $	*/
 
 /*-
  * Copyright (c) 2015 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: svc_fdset.c,v 1.10 2015/11/07 23:17:09 christos Exp $");
+__RCSID("$NetBSD: svc_fdset.c,v 1.11 2015/11/08 02:46:53 christos Exp $");
 
 
 #include "reentrant.h"
@@ -53,7 +53,9 @@ __RCSID("$NetBSD: svc_fdset.c,v 1.10 201
 
 #undef svc_fdset
 #undef svc_maxfd
+#ifdef _LIBC
 extern __fd_set_256 svc_fdset;
+#endif
 extern int svc_maxfd;
 int __svc_flags;
 
@@ -132,11 +134,13 @@ svc_fdset_sanitize(struct svc_fdset *fds
 {
 	while (fds->fdmax >= 0 && !FD_ISSET(fds->fdmax, fds->fdset))
 		fds->fdmax--;
+#ifdef _LIBC
 	/* Compat update */
 	if (fds == &__svc_fdset) {
 		svc_fdset = *(__fd_set_256 *)__svc_fdset.fdset;
 		svc_maxfd = __svc_fdset.fdmax;
 	}
+#endif
 }
 
 static void

Index: src/lib/libc/rpc/svc_fdset.h
diff -u src/lib/libc/rpc/svc_fdset.h:1.3 src/lib/libc/rpc/svc_fdset.h:1.4
--- src/lib/libc/rpc/svc_fdset.h:1.3	Fri Nov  6 19:42:04 2015
+++ src/lib/libc/rpc/svc_fdset.h	Sat Nov  7 21:46:53 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: svc_fdset.h,v 1.3 2015/11/07 00:42:04 christos Exp $	*/
+/*	$NetBSD: svc_fdset.h,v 1.4 2015/11/08 02:46:53 christos Exp $	*/
 
 # ifdef RUMP_RPC
 #  include 
@@ -17,6 +17,8 @@
 #  define	select(a, b, c, d, e)	rump_sys_select(a, b, c, d, e)
 # endif
 
+#ifdef _LIBC
 typedef struct __fd_set_256 {
 	__fd_mask fds_bits[__NFD_LEN(256)];
 } __fd_set_256;
+#endif



CVS commit: src/lib/libc/rpc

2015-11-06 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Nov  6 23:11:09 UTC 2015

Modified Files:
src/lib/libc/rpc: rpc_commondata.c svc_fdset.c

Log Message:
Cleanup and simplify.
undef svc_fdset and svc_maxfd to get to the real data for the compat code.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/lib/libc/rpc/rpc_commondata.c
cvs rdiff -u -r1.3 -r1.4 src/lib/libc/rpc/svc_fdset.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/rpc/rpc_commondata.c
diff -u src/lib/libc/rpc/rpc_commondata.c:1.10 src/lib/libc/rpc/rpc_commondata.c:1.11
--- src/lib/libc/rpc/rpc_commondata.c:1.10	Fri Nov  6 18:05:09 2015
+++ src/lib/libc/rpc/rpc_commondata.c	Fri Nov  6 18:11:09 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: rpc_commondata.c,v 1.10 2015/11/06 23:05:09 joerg Exp $	*/
+/*	$NetBSD: rpc_commondata.c,v 1.11 2015/11/06 23:11:09 christos Exp $	*/
 
 /*
  * Copyright (c) 2010, Oracle America, Inc.
@@ -38,7 +38,7 @@
 #if 0
 static char *sccsid = "@(#)rpc_commondata.c	2.1 88/07/29 4.0 RPCSRC";
 #else
-__RCSID("$NetBSD: rpc_commondata.c,v 1.10 2015/11/06 23:05:09 joerg Exp $");
+__RCSID("$NetBSD: rpc_commondata.c,v 1.11 2015/11/06 23:11:09 christos Exp $");
 #endif
 #endif
 
@@ -49,7 +49,9 @@ __RCSID("$NetBSD: rpc_commondata.c,v 1.1
  * by public interfaces 
  */
 struct opaque_auth _null_auth;
+#undef svc_fdset
 fd_set svc_fdset;
+#undef svc_maxfd
 int svc_maxfd = -1;
 #ifndef _REENTRANT
 #undef rpc_createerr

Index: src/lib/libc/rpc/svc_fdset.c
diff -u src/lib/libc/rpc/svc_fdset.c:1.3 src/lib/libc/rpc/svc_fdset.c:1.4
--- src/lib/libc/rpc/svc_fdset.c:1.3	Fri Nov  6 18:05:09 2015
+++ src/lib/libc/rpc/svc_fdset.c	Fri Nov  6 18:11:09 2015
@@ -1,7 +1,36 @@
-/*	$NetBSD: svc_fdset.c,v 1.3 2015/11/06 23:05:09 joerg Exp $	*/
+/*	$NetBSD: svc_fdset.c,v 1.4 2015/11/06 23:11:09 christos Exp $	*/
+
+/*-
+ * Copyright (c) 2015 The NetBSD Foundation, Inc.
+ * All rights resefdsed.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Christos Zoulas.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
 
 #include 
-__RCSID("$NetBSD: svc_fdset.c,v 1.3 2015/11/06 23:05:09 joerg Exp $");
+__RCSID("$NetBSD: svc_fdset.c,v 1.4 2015/11/06 23:11:09 christos Exp $");
 
 
 #include "reentrant.h"
@@ -13,25 +42,19 @@ __RCSID("$NetBSD: svc_fdset.c,v 1.3 2015
 #include 
 #include 
 
-struct my_svc_fdset {
+#undef svc_fdset
+#undef svc_maxfd
+extern fd_set svc_fdset;
+extern int svc_maxfd;
+
+struct svc_fdset {
 	fd_set *fdset;
 	int	fdmax;
 	int	fdsize;
 };
 
-
 /* The single threaded, one global fd_set version */
-static fd_set *__svc_fdset;
-static int svc_fdsize = 0;
-
-/*
- * Update the old global svc_fdset if needed for binary compatibility
- */
-#define COMPAT_UPDATE(a)\
-	do		\
-		if ((a) == __svc_fdset)			\
-			svc_fdset = *__svc_fdset;	\
-	while (/*CONSTCOND*/0)
+static struct svc_fdset __svc_fdset;
 
 static thread_key_t fdsetkey = -2;
 
@@ -50,8 +73,8 @@ svc_header(const char *func, size_t line
 	va_end(ap);
 }
 
-static void __printflike(5, 6)
-svc_fdset_print(const char *func, size_t line, const fd_set *fds, int fdmax,
+static void __printflike(4, 5)
+svc_fdset_print(const char *func, size_t line, struct svc_fdset *fds, 
 const char *fmt, ...)
 {
 	va_list ap;
@@ -61,12 +84,9 @@ svc_fdset_print(const char *func, size_t
 	svc_header(func, line, fmt, ap);
 	va_end(ap);
 
-	if (fdmax == 0)
-		fdmax = FD_SETSIZE;
-
-	fprintf(stderr, "%p[%d] <", fds, fdmax);
-	for (int i = 0; i <= fdmax; i++) {
-		if (!FD_ISSET(i, fds))
+	fprintf(stderr, "%p[%d] <", fds->fdset, fds->fdmax);
+	for (int i = 0; i <= fds->fdmax; 

CVS commit: src/lib/libc/rpc

2015-11-06 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Nov  7 03:06:33 UTC 2015

Modified Files:
src/lib/libc/rpc: svc_fdset.c

Log Message:
simplify more.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/lib/libc/rpc/svc_fdset.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/rpc/svc_fdset.c
diff -u src/lib/libc/rpc/svc_fdset.c:1.5 src/lib/libc/rpc/svc_fdset.c:1.6
--- src/lib/libc/rpc/svc_fdset.c:1.5	Fri Nov  6 19:42:04 2015
+++ src/lib/libc/rpc/svc_fdset.c	Fri Nov  6 22:06:32 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: svc_fdset.c,v 1.5 2015/11/07 00:42:04 christos Exp $	*/
+/*	$NetBSD: svc_fdset.c,v 1.6 2015/11/07 03:06:32 christos Exp $	*/
 
 /*-
  * Copyright (c) 2015 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: svc_fdset.c,v 1.5 2015/11/07 00:42:04 christos Exp $");
+__RCSID("$NetBSD: svc_fdset.c,v 1.6 2015/11/07 03:06:32 christos Exp $");
 
 
 #include "reentrant.h"
@@ -172,6 +172,9 @@ svc_fdset_alloc(int fd)
 {
 	struct svc_fdset *fds;
 
+	if (!__isthreaded || fdsetkey == -2)
+		return svc_fdset_resize(fd, &__svc_fdset);
+
 	if (fdsetkey == -1)
 		thr_keycreate(, svc_fdset_free);
 
@@ -198,16 +201,6 @@ svc_fdset_alloc(int fd)
 	return svc_fdset_resize(fd, fds);
 }
 
-static struct svc_fdset *
-svc_fdset_get_internal(int fd)
-{
-	if (!__isthreaded || fdsetkey == -2)
-		return svc_fdset_resize(fd, &__svc_fdset);
-
-	return svc_fdset_alloc(fd);
-}
-
-
 /* allow each thread to have their own copy */
 void
 svc_fdset_init(int flags)
@@ -221,18 +214,20 @@ void
 svc_fdset_zero(void)
 {
 	DPRINTF("zero");
-	struct svc_fdset *fds = svc_fdset_get_internal(0);
+	struct svc_fdset *fds = svc_fdset_alloc(0);
 	memset(fds->fdset, 0, fds->fdsize);
-	fds->fdmax = 0;
+	fds->fdmax = -1;
 }
 
 void
 svc_fdset_set(int fd)
 {
-	struct svc_fdset *fds = svc_fdset_get_internal(fd);
+	struct svc_fdset *fds = svc_fdset_alloc(fd);
+
 	FD_SET(fd, fds->fdset);
 	if (fd > fds->fdmax)
 		fds->fdmax = fd;
+
 	DPRINTF_FDSET(fds, "%d", fd);
 
 	svc_fdset_sanitize(fds);
@@ -241,19 +236,22 @@ svc_fdset_set(int fd)
 int
 svc_fdset_isset(int fd)
 {
-	struct svc_fdset *fds = svc_fdset_get_internal(fd);
-	svc_fdset_sanitize(fds);
+	struct svc_fdset *fds = svc_fdset_alloc(fd);
+
 	DPRINTF_FDSET(fds, "%d", fd);
+
 	return FD_ISSET(fd, fds->fdset);
 }
 
 void
 svc_fdset_clr(int fd)
 {
-	struct svc_fdset *fds = svc_fdset_get_internal(fd);
+	struct svc_fdset *fds = svc_fdset_alloc(fd);
+
 	FD_CLR(fd, fds->fdset);
-	svc_fdset_sanitize(fds);
 	DPRINTF_FDSET(fds, "%d", fd);
+
+	svc_fdset_sanitize(fds);
 }
 
 fd_set *
@@ -271,43 +269,28 @@ svc_fdset_copy(const fd_set *orig)
 fd_set *
 svc_fdset_get(void)
 {
-	struct svc_fdset *fds = svc_fdset_get_internal(0);
-	svc_fdset_sanitize(fds);
+	struct svc_fdset *fds = svc_fdset_alloc(0);
 
 	DPRINTF_FDSET(fds, "get");
+	svc_fdset_sanitize(fds);
 	return fds->fdset;
 }
 
 int *
 svc_fdset_getmax(void)
 {
-	struct svc_fdset *fds;
+	struct svc_fdset *fds = svc_fdset_alloc(0);
 
-	if (!__isthreaded || fdsetkey == -2) {
-		svc_fdset_sanitize(&__svc_fdset);
-		return &__svc_fdset.fdmax;
-	}
-		
-	fds = svc_fdset_alloc(0);
-	if (fds == NULL)
-		return NULL;
+	DPRINTF_FDSET(fds, "getmax");
+	svc_fdset_sanitize(fds);
 	return >fdmax;
 }
 
 int
 svc_fdset_getsize(int fd)
 {
-	struct svc_fdset *fds;
-
-	if (!__isthreaded || fdsetkey == -2) {
-		if (svc_fdset_resize(fd, &__svc_fdset) == NULL)
-			return -1;
-		else
-			return __svc_fdset.fdsize;
-	}
+	struct svc_fdset *fds = svc_fdset_alloc(fd);
 
-	fds = svc_fdset_alloc(fd);
-	if (fds == NULL)
-		return -1;
+	DPRINTF_FDSET(fds, "getsize");
 	return fds->fdsize;
 }



CVS commit: src/lib/libc/rpc

2015-11-06 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Fri Nov  6 23:05:09 UTC 2015

Modified Files:
src/lib/libc/rpc: rpc_commondata.c svc_fdset.c

Log Message:
Don't use macros as types or variable names.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/lib/libc/rpc/rpc_commondata.c
cvs rdiff -u -r1.2 -r1.3 src/lib/libc/rpc/svc_fdset.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/rpc/rpc_commondata.c
diff -u src/lib/libc/rpc/rpc_commondata.c:1.9 src/lib/libc/rpc/rpc_commondata.c:1.10
--- src/lib/libc/rpc/rpc_commondata.c:1.9	Mon Mar 11 20:19:29 2013
+++ src/lib/libc/rpc/rpc_commondata.c	Fri Nov  6 23:05:09 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: rpc_commondata.c,v 1.9 2013/03/11 20:19:29 tron Exp $	*/
+/*	$NetBSD: rpc_commondata.c,v 1.10 2015/11/06 23:05:09 joerg Exp $	*/
 
 /*
  * Copyright (c) 2010, Oracle America, Inc.
@@ -31,12 +31,14 @@
  *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#define SVC_LEGACY
+
 #include 
 #if defined(LIBC_SCCS) && !defined(lint)
 #if 0
 static char *sccsid = "@(#)rpc_commondata.c	2.1 88/07/29 4.0 RPCSRC";
 #else
-__RCSID("$NetBSD: rpc_commondata.c,v 1.9 2013/03/11 20:19:29 tron Exp $");
+__RCSID("$NetBSD: rpc_commondata.c,v 1.10 2015/11/06 23:05:09 joerg Exp $");
 #endif
 #endif
 

Index: src/lib/libc/rpc/svc_fdset.c
diff -u src/lib/libc/rpc/svc_fdset.c:1.2 src/lib/libc/rpc/svc_fdset.c:1.3
--- src/lib/libc/rpc/svc_fdset.c:1.2	Fri Nov  6 19:34:13 2015
+++ src/lib/libc/rpc/svc_fdset.c	Fri Nov  6 23:05:09 2015
@@ -1,7 +1,7 @@
-/*	$NetBSD: svc_fdset.c,v 1.2 2015/11/06 19:34:13 christos Exp $	*/
+/*	$NetBSD: svc_fdset.c,v 1.3 2015/11/06 23:05:09 joerg Exp $	*/
 
 #include 
-__RCSID("$NetBSD: svc_fdset.c,v 1.2 2015/11/06 19:34:13 christos Exp $");
+__RCSID("$NetBSD: svc_fdset.c,v 1.3 2015/11/06 23:05:09 joerg Exp $");
 
 
 #include "reentrant.h"
@@ -13,7 +13,7 @@ __RCSID("$NetBSD: svc_fdset.c,v 1.2 2015
 #include 
 #include 
 
-struct svc_fdset {
+struct my_svc_fdset {
 	fd_set *fdset;
 	int	fdmax;
 	int	fdsize;
@@ -96,7 +96,7 @@ svc_print(const char *func, size_t line,
 static void
 svc_fdset_free(void *v)
 {
-	struct svc_fdset *rv = v;
+	struct my_svc_fdset *rv = v;
 	DPRINTF_FDSET(rv->fdset, 0, "free");
 
 	free(rv->fdset);
@@ -133,10 +133,10 @@ svc_fdset_resize(int fd, fd_set **fdset,
 	return *fdset;
 }
 
-static struct svc_fdset *
+static struct my_svc_fdset *
 svc_fdset_alloc(int fd)
 {
-	struct svc_fdset *rv;
+	struct my_svc_fdset *rv;
 
 	if (fdsetkey == -1)
 		thr_keycreate(, svc_fdset_free);
@@ -172,7 +172,7 @@ svc_fdset_alloc(int fd)
 static fd_set *
 svc_fdset_get_internal(int fd)
 {
-	struct svc_fdset *rv;
+	struct my_svc_fdset *rv;
 
 	if (!__isthreaded || fdsetkey == -2)
 		return svc_fdset_resize(fd, &__svc_fdset, _fdsize);
@@ -270,7 +270,7 @@ svc_fdset_get(void)
 int *
 svc_fdset_getmax(void)
 {
-	struct svc_fdset *rv;
+	struct my_svc_fdset *rv;
 
 	if (!__isthreaded || fdsetkey == -2)
 		return _maxfd;
@@ -284,7 +284,7 @@ svc_fdset_getmax(void)
 int
 svc_fdset_getsize(int fd)
 {
-	struct svc_fdset *rv;
+	struct my_svc_fdset *rv;
 
 	if (!__isthreaded || fdsetkey == -2) {
 		if (svc_fdset_resize(fd, &__svc_fdset, _fdsize) == NULL)



CVS commit: src/lib/libc/rpc

2015-11-06 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Nov  7 00:42:04 UTC 2015

Modified Files:
src/lib/libc/rpc: rpc_commondata.c svc_fdset.c svc_fdset.h

Log Message:
Introduce a binary compatible __fd_set_256 that is what the original fdset
size was for libc. Now we can bump it.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/lib/libc/rpc/rpc_commondata.c
cvs rdiff -u -r1.4 -r1.5 src/lib/libc/rpc/svc_fdset.c
cvs rdiff -u -r1.2 -r1.3 src/lib/libc/rpc/svc_fdset.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/rpc/rpc_commondata.c
diff -u src/lib/libc/rpc/rpc_commondata.c:1.11 src/lib/libc/rpc/rpc_commondata.c:1.12
--- src/lib/libc/rpc/rpc_commondata.c:1.11	Fri Nov  6 18:11:09 2015
+++ src/lib/libc/rpc/rpc_commondata.c	Fri Nov  6 19:42:04 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: rpc_commondata.c,v 1.11 2015/11/06 23:11:09 christos Exp $	*/
+/*	$NetBSD: rpc_commondata.c,v 1.12 2015/11/07 00:42:04 christos Exp $	*/
 
 /*
  * Copyright (c) 2010, Oracle America, Inc.
@@ -38,11 +38,12 @@
 #if 0
 static char *sccsid = "@(#)rpc_commondata.c	2.1 88/07/29 4.0 RPCSRC";
 #else
-__RCSID("$NetBSD: rpc_commondata.c,v 1.11 2015/11/06 23:11:09 christos Exp $");
+__RCSID("$NetBSD: rpc_commondata.c,v 1.12 2015/11/07 00:42:04 christos Exp $");
 #endif
 #endif
 
 #include 
+#include "svc_fdset.h"
 
 /*
  * This file should only contain common data (global data) that is exported
@@ -50,7 +51,7 @@ __RCSID("$NetBSD: rpc_commondata.c,v 1.1
  */
 struct opaque_auth _null_auth;
 #undef svc_fdset
-fd_set svc_fdset;
+__fd_set_256 svc_fdset;
 #undef svc_maxfd
 int svc_maxfd = -1;
 #ifndef _REENTRANT

Index: src/lib/libc/rpc/svc_fdset.c
diff -u src/lib/libc/rpc/svc_fdset.c:1.4 src/lib/libc/rpc/svc_fdset.c:1.5
--- src/lib/libc/rpc/svc_fdset.c:1.4	Fri Nov  6 18:11:09 2015
+++ src/lib/libc/rpc/svc_fdset.c	Fri Nov  6 19:42:04 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: svc_fdset.c,v 1.4 2015/11/06 23:11:09 christos Exp $	*/
+/*	$NetBSD: svc_fdset.c,v 1.5 2015/11/07 00:42:04 christos Exp $	*/
 
 /*-
  * Copyright (c) 2015 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: svc_fdset.c,v 1.4 2015/11/06 23:11:09 christos Exp $");
+__RCSID("$NetBSD: svc_fdset.c,v 1.5 2015/11/07 00:42:04 christos Exp $");
 
 
 #include "reentrant.h"
@@ -39,12 +39,20 @@ __RCSID("$NetBSD: svc_fdset.c,v 1.4 2015
 
 #include 
 
+#ifdef FDSET_DEBUG
+#include 
+#include 
+#include 
+#include 
+#endif
 #include 
 #include 
 
+#include "svc_fdset.h"
+
 #undef svc_fdset
 #undef svc_maxfd
-extern fd_set svc_fdset;
+extern __fd_set_256 svc_fdset;
 extern int svc_maxfd;
 
 struct svc_fdset {
@@ -59,10 +67,6 @@ static struct svc_fdset __svc_fdset;
 static thread_key_t fdsetkey = -2;
 
 #ifdef FDSET_DEBUG
-#include 
-#include 
-#include 
-#include 
 
 static void  __printflike(3, 0)
 svc_header(const char *func, size_t line, const char *fmt, va_list ap)
@@ -123,7 +127,7 @@ svc_fdset_sanitize(struct svc_fdset *fds
 		fds->fdmax--;
 	/* Compat update */
 	if (fds == &__svc_fdset) {
-		svc_fdset = *__svc_fdset.fdset;
+		svc_fdset = *(__fd_set_256 *)__svc_fdset.fdset;
 		svc_maxfd = __svc_fdset.fdmax;
 	}
 }

Index: src/lib/libc/rpc/svc_fdset.h
diff -u src/lib/libc/rpc/svc_fdset.h:1.2 src/lib/libc/rpc/svc_fdset.h:1.3
--- src/lib/libc/rpc/svc_fdset.h:1.2	Fri Nov  6 14:34:13 2015
+++ src/lib/libc/rpc/svc_fdset.h	Fri Nov  6 19:42:04 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: svc_fdset.h,v 1.2 2015/11/06 19:34:13 christos Exp $	*/
+/*	$NetBSD: svc_fdset.h,v 1.3 2015/11/07 00:42:04 christos Exp $	*/
 
 # ifdef RUMP_RPC
 #  include 
@@ -16,3 +16,7 @@
 #  undef	select
 #  define	select(a, b, c, d, e)	rump_sys_select(a, b, c, d, e)
 # endif
+
+typedef struct __fd_set_256 {
+	__fd_mask fds_bits[__NFD_LEN(256)];
+} __fd_set_256;



CVS commit: src/lib/libc/rpc

2015-11-06 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Nov  6 19:32:08 UTC 2015

Modified Files:
src/lib/libc/rpc: clnt_raw.c svc_raw.c

Log Message:
- Use -1 for the fake raw fd since we will be able to go beyond FD_SETSIZE.
- Poster boy for why it is bad to initialize in declarations :-)


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/lib/libc/rpc/clnt_raw.c
cvs rdiff -u -r1.24 -r1.25 src/lib/libc/rpc/svc_raw.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/rpc/clnt_raw.c
diff -u src/lib/libc/rpc/clnt_raw.c:1.32 src/lib/libc/rpc/clnt_raw.c:1.33
--- src/lib/libc/rpc/clnt_raw.c:1.32	Mon Mar 11 16:19:29 2013
+++ src/lib/libc/rpc/clnt_raw.c	Fri Nov  6 14:32:08 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: clnt_raw.c,v 1.32 2013/03/11 20:19:29 tron Exp $	*/
+/*	$NetBSD: clnt_raw.c,v 1.33 2015/11/06 19:32:08 christos Exp $	*/
 
 /*
  * Copyright (c) 2010, Oracle America, Inc.
@@ -37,7 +37,7 @@
 static char *sccsid = "@(#)clnt_raw.c 1.22 87/08/11 Copyr 1984 Sun Micro";
 static char *sccsid = "@(#)clnt_raw.c	2.2 88/08/01 4.0 RPCSRC";
 #else
-__RCSID("$NetBSD: clnt_raw.c,v 1.32 2013/03/11 20:19:29 tron Exp $");
+__RCSID("$NetBSD: clnt_raw.c,v 1.33 2015/11/06 19:32:08 christos Exp $");
 #endif
 #endif
 
@@ -102,13 +102,13 @@ static struct clnt_ops *clnt_raw_ops(voi
 CLIENT *
 clnt_raw_create(rpcprog_t prog, rpcvers_t vers)
 {
-	struct clntraw_private *clp = clntraw_private;
+	struct clntraw_private *clp;
 	struct rpc_msg call_msg;
-	XDR *xdrs = >xdr_stream;
-	CLIENT	*client = >client_object;
+	XDR *xdrs;
+	CLIENT *client;
 
 	mutex_lock(_lock);
-	if (clp == NULL) {
+	if ((clp = clntraw_private) == NULL) {
 		clp = calloc((size_t)1, sizeof (*clp));
 		if (clp == NULL)
 			goto out;
@@ -120,6 +120,10 @@ clnt_raw_create(rpcprog_t prog, rpcvers_
 		clp->_raw_buf = __rpc_rawcombuf;
 		clntraw_private = clp;
 	}
+
+	xdrs = >xdr_stream;
+	client = >client_object;
+
 	/*
 	 * pre-serialize the static part of the call msg and stash it away
 	 */
@@ -193,7 +197,7 @@ call_again:
 	 * We have to call server input routine here because this is
 	 * all going on in one process. Yuk.
 	 */
-	svc_getreq_common(FD_SETSIZE);
+	svc_getreq_common(-1);
 
 	/*
 	 * get results

Index: src/lib/libc/rpc/svc_raw.c
diff -u src/lib/libc/rpc/svc_raw.c:1.24 src/lib/libc/rpc/svc_raw.c:1.25
--- src/lib/libc/rpc/svc_raw.c:1.24	Mon Mar 11 16:19:29 2013
+++ src/lib/libc/rpc/svc_raw.c	Fri Nov  6 14:32:08 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: svc_raw.c,v 1.24 2013/03/11 20:19:29 tron Exp $	*/
+/*	$NetBSD: svc_raw.c,v 1.25 2015/11/06 19:32:08 christos Exp $	*/
 
 /*
  * Copyright (c) 2010, Oracle America, Inc.
@@ -41,7 +41,7 @@
 #if 0
 static char sccsid[] = "@(#)svc_raw.c 1.25 89/01/31 Copyr 1984 Sun Micro";
 #else
-__RCSID("$NetBSD: svc_raw.c,v 1.24 2013/03/11 20:19:29 tron Exp $");
+__RCSID("$NetBSD: svc_raw.c,v 1.25 2015/11/06 19:32:08 christos Exp $");
 #endif
 #endif
 
@@ -113,7 +113,7 @@ svc_raw_create(void)
 		srp->raw_buf = __rpc_rawcombuf; /* Share it with the client */
 		svc_raw_private = srp;
 	}
-	srp->server.xp_fd = FD_SETSIZE;
+	srp->server.xp_fd = -1;
 	srp->server.xp_port = 0;
 	srp->server.xp_p3 = NULL;
 	svc_raw_ops(>server);



CVS commit: src/lib/libc/rpc

2015-11-06 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Nov  6 19:34:14 UTC 2015

Modified Files:
src/lib/libc/rpc: Makefile.inc svc.c svc_fdset.c svc_fdset.h svc_run.c
svc_vc.c

Log Message:
- Provide multi-threaded fdset's for everyone not just rump if requested.
- Abstract fd_set access, and don't limit the fd_set size.
- Maintain binary compatibility by keeping the old global variables around.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/lib/libc/rpc/Makefile.inc \
src/lib/libc/rpc/svc_run.c
cvs rdiff -u -r1.34 -r1.35 src/lib/libc/rpc/svc.c
cvs rdiff -u -r1.1 -r1.2 src/lib/libc/rpc/svc_fdset.c \
src/lib/libc/rpc/svc_fdset.h
cvs rdiff -u -r1.30 -r1.31 src/lib/libc/rpc/svc_vc.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/rpc/Makefile.inc
diff -u src/lib/libc/rpc/Makefile.inc:1.22 src/lib/libc/rpc/Makefile.inc:1.23
--- src/lib/libc/rpc/Makefile.inc:1.22	Wed Apr 15 15:13:47 2015
+++ src/lib/libc/rpc/Makefile.inc	Fri Nov  6 14:34:13 2015
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.inc,v 1.22 2015/04/15 19:13:47 mrg Exp $
+#	$NetBSD: Makefile.inc,v 1.23 2015/11/06 19:34:13 christos Exp $
 
 # librpc sources
 .PATH:	${.CURDIR}/rpc
@@ -12,7 +12,7 @@ SRCS+=	auth_none.c auth_unix.c authunix_
 	pmap_prot2.c pmap_rmt.c rpc_prot.c rpc_commondata.c rpc_callmsg.c \
 	rpc_generic.c rpc_soc.c rpcb_clnt.c rpcb_prot.c rpcb_st_xdr.c \
 	svc.c svc_auth.c svc_dg.c svc_auth_unix.c svc_generic.c svc_raw.c \
-	svc_run.c svc_simple.c svc_vc.c \
+	svc_run.c svc_simple.c svc_vc.c svc_fdset.c \
 	xdr.c xdr_array.c xdr_float.c xdr_mem.c xdr_rec.c xdr_reference.c \
 	xdr_stdio.c xdr_sizeof.c __rpc_getxid.c
 
Index: src/lib/libc/rpc/svc_run.c
diff -u src/lib/libc/rpc/svc_run.c:1.22 src/lib/libc/rpc/svc_run.c:1.23
--- src/lib/libc/rpc/svc_run.c:1.22	Mon Mar 11 16:19:29 2013
+++ src/lib/libc/rpc/svc_run.c	Fri Nov  6 14:34:13 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: svc_run.c,v 1.22 2013/03/11 20:19:29 tron Exp $	*/
+/*	$NetBSD: svc_run.c,v 1.23 2015/11/06 19:34:13 christos Exp $	*/
 
 /*
  * Copyright (c) 2010, Oracle America, Inc.
@@ -37,7 +37,7 @@
 static char *sccsid = "@(#)svc_run.c 1.1 87/10/13 Copyr 1984 Sun Micro";
 static char *sccsid = "@(#)svc_run.c	2.1 88/07/29 4.0 RPCSRC";
 #else
-__RCSID("$NetBSD: svc_run.c,v 1.22 2013/03/11 20:19:29 tron Exp $");
+__RCSID("$NetBSD: svc_run.c,v 1.23 2015/11/06 19:34:13 christos Exp $");
 #endif
 #endif
 
@@ -50,6 +50,7 @@ __RCSID("$NetBSD: svc_run.c,v 1.22 2013/
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -66,9 +67,9 @@ __weak_alias(svc_exit,_svc_exit)
 void
 svc_run(void)
 {
-	fd_set readfds, cleanfds;
+	fd_set *readfds, *cleanfds;
 	struct timeval timeout;
-	int maxfd;
+	int maxfd, fdsize;
 #ifndef RUMP_RPC		
 	int probs = 0;
 #endif
@@ -76,16 +77,24 @@ svc_run(void)
 	extern rwlock_t svc_fd_lock;
 #endif
 
+	readfds = NULL;
+	cleanfds = NULL;
+	fdsize = 0;
 	timeout.tv_sec = 30;
 	timeout.tv_usec = 0;
 
 	for (;;) {
 		rwlock_rdlock(_fd_lock);
-		readfds = *get_fdset();
-		cleanfds = *get_fdset();
-		maxfd = *get_fdsetmax();
+		if (fdsize != svc_fdset_getsize(0)) {
+			fdsize = svc_fdset_getsize(0);
+			free(readfds);
+			readfds = svc_fdset_copy(svc_fdset_get());
+			free(cleanfds);
+			cleanfds = svc_fdset_copy(svc_fdset_get());
+		}
+		maxfd = *svc_fdset_getmax();
 		rwlock_unlock(_fd_lock);
-		switch (select(maxfd + 1, , NULL, NULL, )) {
+		switch (select(maxfd + 1, readfds, NULL, NULL, )) {
 		case -1:
 #ifndef RUMP_RPC		
 			if ((errno == EINTR || errno == EBADF) && probs < 100) {
@@ -97,17 +106,20 @@ svc_run(void)
 continue;
 			}
 			warn("%s: select failed", __func__);
-			return;
+			goto out;
 		case 0:
-			__svc_clean_idle(, 30, FALSE);
+			__svc_clean_idle(cleanfds, 30, FALSE);
 			continue;
 		default:
-			svc_getreqset();
+			svc_getreqset2(readfds, fdsize);
 #ifndef RUMP_RPC
 			probs = 0;
 #endif
 		}
 	}
+out:
+	free(readfds);
+	free(cleanfds);
 }
 
 /*
@@ -122,6 +134,6 @@ svc_exit(void)
 #endif
 
 	rwlock_wrlock(_fd_lock);
-	FD_ZERO(get_fdset());
+	svc_fdset_zero();
 	rwlock_unlock(_fd_lock);
 }

Index: src/lib/libc/rpc/svc.c
diff -u src/lib/libc/rpc/svc.c:1.34 src/lib/libc/rpc/svc.c:1.35
--- src/lib/libc/rpc/svc.c:1.34	Mon Mar 11 16:19:29 2013
+++ src/lib/libc/rpc/svc.c	Fri Nov  6 14:34:13 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: svc.c,v 1.34 2013/03/11 20:19:29 tron Exp $	*/
+/*	$NetBSD: svc.c,v 1.35 2015/11/06 19:34:13 christos Exp $	*/
 
 /*
  * Copyright (c) 2010, Oracle America, Inc.
@@ -37,7 +37,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.34 2013/03/11 20:19:29 tron Exp $");
+__RCSID("$NetBSD: svc.c,v 1.35 2015/11/06 19:34:13 christos Exp $");
 #endif
 #endif
 
@@ -90,7 +90,9 @@ __weak_alias(xprt_unregister,_xprt_unreg
 __weak_alias(rpc_control,_rpc_control)
 

CVS commit: src/lib/libc/rpc

2015-03-26 Thread Justin Cormack
Module Name:src
Committed By:   justin
Date:   Thu Mar 26 11:31:57 UTC 2015

Modified Files:
src/lib/libc/rpc: rpcb_clnt.c xdr_rec.c

Log Message:
Fix definitions to match headers


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/lib/libc/rpc/rpcb_clnt.c
cvs rdiff -u -r1.35 -r1.36 src/lib/libc/rpc/xdr_rec.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/rpc/rpcb_clnt.c
diff -u src/lib/libc/rpc/rpcb_clnt.c:1.30 src/lib/libc/rpc/rpcb_clnt.c:1.31
--- src/lib/libc/rpc/rpcb_clnt.c:1.30	Thu Jan  2 20:12:23 2014
+++ src/lib/libc/rpc/rpcb_clnt.c	Thu Mar 26 11:31:57 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: rpcb_clnt.c,v 1.30 2014/01/02 20:12:23 christos Exp $	*/
+/*	$NetBSD: rpcb_clnt.c,v 1.31 2015/03/26 11:31:57 justin Exp $	*/
 
 /*
  * Copyright (c) 2010, Oracle America, Inc.
@@ -41,7 +41,7 @@
 #if 0
 static char sccsid[] = @(#)rpcb_clnt.c 1.30 89/06/21 Copyr 1988 Sun Micro;
 #else
-__RCSID($NetBSD: rpcb_clnt.c,v 1.30 2014/01/02 20:12:23 christos Exp $);
+__RCSID($NetBSD: rpcb_clnt.c,v 1.31 2015/03/26 11:31:57 justin Exp $);
 #endif
 #endif
 
@@ -983,8 +983,8 @@ done:
  *
  * Assuming that the address is all properly allocated
  */
-int
-rpcb_getaddr(rpcprog_t program, rpcvers_t version,
+bool_t
+rpcb_getaddr(const rpcprog_t program, const rpcvers_t version,
 	const struct netconfig *nconf, struct netbuf *address,
 	const char *host)
 {

Index: src/lib/libc/rpc/xdr_rec.c
diff -u src/lib/libc/rpc/xdr_rec.c:1.35 src/lib/libc/rpc/xdr_rec.c:1.36
--- src/lib/libc/rpc/xdr_rec.c:1.35	Mon Mar 11 20:19:30 2013
+++ src/lib/libc/rpc/xdr_rec.c	Thu Mar 26 11:31:57 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: xdr_rec.c,v 1.35 2013/03/11 20:19:30 tron Exp $	*/
+/*	$NetBSD: xdr_rec.c,v 1.36 2015/03/26 11:31:57 justin Exp $	*/
 
 /*
  * Copyright (c) 2010, Oracle America, Inc.
@@ -37,7 +37,7 @@
 static char *sccsid = @(#)xdr_rec.c 1.21 87/08/11 Copyr 1984 Sun Micro;
 static char *sccsid = @(#)xdr_rec.c	2.2 88/08/01 4.0 RPCSRC;
 #else
-__RCSID($NetBSD: xdr_rec.c,v 1.35 2013/03/11 20:19:30 tron Exp $);
+__RCSID($NetBSD: xdr_rec.c,v 1.36 2015/03/26 11:31:57 justin Exp $);
 #endif
 #endif
 
@@ -507,7 +507,7 @@ xdrrec_eof(XDR *xdrs)
  * pipelined procedure calls.)  TRUE = immmediate flush to tcp connection.
  */
 bool_t
-xdrrec_endofrecord(XDR *xdrs, bool_t sendnow)
+xdrrec_endofrecord(XDR *xdrs, int sendnow)
 {
 	RECSTREAM *rstrm = (RECSTREAM *)(xdrs-x_private);
 	u_long len;  /* fragment length */



CVS commit: src/lib/libc/rpc

2014-08-24 Thread Matt Thomas
Module Name:src
Committed By:   matt
Date:   Sun Aug 24 17:07:00 UTC 2014

Modified Files:
src/lib/libc/rpc: xdr_float.c

Log Message:
Assume anything not vax has IEEEFP.


To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.40 src/lib/libc/rpc/xdr_float.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/rpc/xdr_float.c
diff -u src/lib/libc/rpc/xdr_float.c:1.39 src/lib/libc/rpc/xdr_float.c:1.40
--- src/lib/libc/rpc/xdr_float.c:1.39	Sun Aug 10 05:57:31 2014
+++ src/lib/libc/rpc/xdr_float.c	Sun Aug 24 17:07:00 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: xdr_float.c,v 1.39 2014/08/10 05:57:31 matt Exp $	*/
+/*	$NetBSD: xdr_float.c,v 1.40 2014/08/24 17:07:00 matt Exp $	*/
 
 /*
  * Copyright (c) 2010, Oracle America, Inc.
@@ -37,7 +37,7 @@
 static char *sccsid = @(#)xdr_float.c 1.12 87/08/11 Copyr 1984 Sun Micro;
 static char *sccsid = @(#)xdr_float.c	2.1 88/07/29 4.0 RPCSRC;
 #else
-__RCSID($NetBSD: xdr_float.c,v 1.39 2014/08/10 05:57:31 matt Exp $);
+__RCSID($NetBSD: xdr_float.c,v 1.40 2014/08/24 17:07:00 matt Exp $);
 #endif
 #endif
 
@@ -71,11 +71,7 @@ __weak_alias(xdr_float,_xdr_float)
  * This routine works on machines with IEEE754 FP and Vaxen.
  */
 
-#if defined(__m68k__) || defined(__sparc__) || defined(__i386__) || \
-defined(__mips__) || defined(__ns32k__) || defined(__alpha__) || \
-defined(__arm__) || defined(__powerpc__) || defined(__sh__) || \
-defined(__x86_64__) || defined(__hppa__) || defined(__ia64__) || \
-defined(__aarch64__)
+#if !defined(__vax__)
 #include machine/endian.h
 #define IEEEFP
 #endif



CVS commit: src/lib/libc/rpc

2014-05-29 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu May 29 12:35:45 UTC 2014

Modified Files:
src/lib/libc/rpc: svc_generic.c

Log Message:
Don't try to listen on UDP sockets.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/lib/libc/rpc/svc_generic.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/rpc/svc_generic.c
diff -u src/lib/libc/rpc/svc_generic.c:1.16 src/lib/libc/rpc/svc_generic.c:1.17
--- src/lib/libc/rpc/svc_generic.c:1.16	Wed May 28 10:49:28 2014
+++ src/lib/libc/rpc/svc_generic.c	Thu May 29 08:35:45 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: svc_generic.c,v 1.16 2014/05/28 14:49:28 christos Exp $	*/
+/*	$NetBSD: svc_generic.c,v 1.17 2014/05/29 12:35:45 christos Exp $	*/
 
 /*
  * Copyright (c) 2010, Oracle America, Inc.
@@ -42,7 +42,7 @@
 #if 0
 static char sccsid[] = @(#)svc_generic.c 1.21 89/02/28 Copyr 1988 Sun Micro;
 #else
-__RCSID($NetBSD: svc_generic.c,v 1.16 2014/05/28 14:49:28 christos Exp $);
+__RCSID($NetBSD: svc_generic.c,v 1.17 2014/05/29 12:35:45 christos Exp $);
 #endif
 #endif
 
@@ -251,7 +251,8 @@ svc_tli_create(
 	goto freedata;
 }
 			}
-			if (listen(fd, SOMAXCONN) == -1) {
+			if (si.si_socktype != SOCK_DGRAM 
+			listen(fd, SOMAXCONN) == -1) {
 warnx(%s: could not listen at anonymous port,
 __func__);
 goto freedata;
@@ -264,7 +265,8 @@ svc_tli_create(
 __func__);
 goto freedata;
 			}
-			if (listen(fd, (int)bindaddr-qlen) == -1) {
+			if (si.si_socktype != SOCK_DGRAM 
+			listen(fd, (int)bindaddr-qlen) == -1) {
 warnx(%s: could not listen at requested 
 address, __func__);
 goto freedata;



CVS commit: src/lib/libc/rpc

2014-05-28 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed May 28 14:41:48 UTC 2014

Modified Files:
src/lib/libc/rpc: clnt_generic.c

Log Message:
CID 975112: Ignore bindresvport() return. This is can only succeed for root


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/lib/libc/rpc/clnt_generic.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/rpc/clnt_generic.c
diff -u src/lib/libc/rpc/clnt_generic.c:1.31 src/lib/libc/rpc/clnt_generic.c:1.32
--- src/lib/libc/rpc/clnt_generic.c:1.31	Tue May  7 17:08:45 2013
+++ src/lib/libc/rpc/clnt_generic.c	Wed May 28 10:41:47 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: clnt_generic.c,v 1.31 2013/05/07 21:08:45 christos Exp $	*/
+/*	$NetBSD: clnt_generic.c,v 1.32 2014/05/28 14:41:47 christos Exp $	*/
 
 /*
  * Copyright (c) 2010, Oracle America, Inc.
@@ -41,7 +41,7 @@
 #if 0
 static char sccsid[] = @(#)clnt_generic.c 1.32 89/03/16 Copyr 1988 Sun Micro;
 #else
-__RCSID($NetBSD: clnt_generic.c,v 1.31 2013/05/07 21:08:45 christos Exp $);
+__RCSID($NetBSD: clnt_generic.c,v 1.32 2014/05/28 14:41:47 christos Exp $);
 #endif
 #endif
 
@@ -321,7 +321,7 @@ clnt_tli_create(
 		if (!__rpc_fd2sockinfo(fd, si))
 			goto err;
 
-		bindresvport(fd, NULL);
+		(void)bindresvport(fd, NULL);
 	} else {
 		if (!__rpc_fd2sockinfo(fd, si))
 			goto err;



CVS commit: src/lib/libc/rpc

2014-05-28 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed May 28 14:45:20 UTC 2014

Modified Files:
src/lib/libc/rpc: clnt_generic.c

Log Message:
CID 975113: Ignore __rpc_setnodelay error, it is not fatal


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/lib/libc/rpc/clnt_generic.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/rpc/clnt_generic.c
diff -u src/lib/libc/rpc/clnt_generic.c:1.32 src/lib/libc/rpc/clnt_generic.c:1.33
--- src/lib/libc/rpc/clnt_generic.c:1.32	Wed May 28 10:41:47 2014
+++ src/lib/libc/rpc/clnt_generic.c	Wed May 28 10:45:19 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: clnt_generic.c,v 1.32 2014/05/28 14:41:47 christos Exp $	*/
+/*	$NetBSD: clnt_generic.c,v 1.33 2014/05/28 14:45:19 christos Exp $	*/
 
 /*
  * Copyright (c) 2010, Oracle America, Inc.
@@ -41,7 +41,7 @@
 #if 0
 static char sccsid[] = @(#)clnt_generic.c 1.32 89/03/16 Copyr 1988 Sun Micro;
 #else
-__RCSID($NetBSD: clnt_generic.c,v 1.32 2014/05/28 14:41:47 christos Exp $);
+__RCSID($NetBSD: clnt_generic.c,v 1.33 2014/05/28 14:45:19 christos Exp $);
 #endif
 #endif
 
@@ -343,7 +343,7 @@ clnt_tli_create(
 		cl = clnt_vc_create(fd, svcaddr, prog, vers, sendsz, recvsz);
 		if (!nconf || !cl)
 			break;
-		__rpc_setnodelay(fd, si);
+		(void)__rpc_setnodelay(fd, si);
 		break;
 	case NC_TPI_CLTS:
 		cl = clnt_dg_create(fd, svcaddr, prog, vers, sendsz, recvsz);



CVS commit: src/lib/libc/rpc

2014-05-28 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed May 28 14:45:57 UTC 2014

Modified Files:
src/lib/libc/rpc: rpc_soc.c

Log Message:
CID 97511{4,5}: Ignore bindresvport return. It only works for root.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/lib/libc/rpc/rpc_soc.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/rpc/rpc_soc.c
diff -u src/lib/libc/rpc/rpc_soc.c:1.18 src/lib/libc/rpc/rpc_soc.c:1.19
--- src/lib/libc/rpc/rpc_soc.c:1.18	Mon Mar 11 16:19:29 2013
+++ src/lib/libc/rpc/rpc_soc.c	Wed May 28 10:45:57 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: rpc_soc.c,v 1.18 2013/03/11 20:19:29 tron Exp $	*/
+/*	$NetBSD: rpc_soc.c,v 1.19 2014/05/28 14:45:57 christos Exp $	*/
 
 /*
  * Copyright (c) 2010, Oracle America, Inc.
@@ -45,7 +45,7 @@
 #if 0
 static char sccsid[] = @(#)rpc_soc.c 1.41 89/05/02 Copyr 1988 Sun Micro;
 #else
-__RCSID($NetBSD: rpc_soc.c,v 1.18 2013/03/11 20:19:29 tron Exp $);
+__RCSID($NetBSD: rpc_soc.c,v 1.19 2014/05/28 14:45:57 christos Exp $);
 #endif
 #endif
 
@@ -156,7 +156,7 @@ clnt_com_create(struct sockaddr_in *radd
 	bindaddr.maxlen = bindaddr.len =  sizeof (struct sockaddr_in);
 	bindaddr.buf = raddr;
 
-	bindresvport(fd, NULL);
+	(void)bindresvport(fd, NULL);
 	cl = clnt_tli_create(fd, nconf, bindaddr, prog, vers,
 sendsz, recvsz);
 	if (cl) {
@@ -254,7 +254,7 @@ svc_com_create(int fd, u_int sendsize, u
 
 	memset(sccsin, 0, sizeof sccsin);
 	sccsin.sin_family = AF_INET;
-	bindresvport(fd, sccsin);
+	(void)bindresvport(fd, sccsin);
 	listen(fd, SOMAXCONN);
 	svc = svc_tli_create(fd, nconf, NULL, sendsize, recvsize);
 	(void) freenetconfigent(nconf);



CVS commit: src/lib/libc/rpc

2014-05-28 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed May 28 14:49:28 UTC 2014

Modified Files:
src/lib/libc/rpc: svc_generic.c

Log Message:
CID 975117: check listen(2) return .


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/lib/libc/rpc/svc_generic.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/rpc/svc_generic.c
diff -u src/lib/libc/rpc/svc_generic.c:1.15 src/lib/libc/rpc/svc_generic.c:1.16
--- src/lib/libc/rpc/svc_generic.c:1.15	Mon Mar 11 16:19:29 2013
+++ src/lib/libc/rpc/svc_generic.c	Wed May 28 10:49:28 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: svc_generic.c,v 1.15 2013/03/11 20:19:29 tron Exp $	*/
+/*	$NetBSD: svc_generic.c,v 1.16 2014/05/28 14:49:28 christos Exp $	*/
 
 /*
  * Copyright (c) 2010, Oracle America, Inc.
@@ -42,7 +42,7 @@
 #if 0
 static char sccsid[] = @(#)svc_generic.c 1.21 89/02/28 Copyr 1988 Sun Micro;
 #else
-__RCSID($NetBSD: svc_generic.c,v 1.15 2013/03/11 20:19:29 tron Exp $);
+__RCSID($NetBSD: svc_generic.c,v 1.16 2014/05/28 14:49:28 christos Exp $);
 #endif
 #endif
 
@@ -251,7 +251,11 @@ svc_tli_create(
 	goto freedata;
 }
 			}
-			listen(fd, SOMAXCONN);
+			if (listen(fd, SOMAXCONN) == -1) {
+warnx(%s: could not listen at anonymous port,
+__func__);
+goto freedata;
+			}
 		} else {
 			if (bind(fd,
 			(struct sockaddr *)bindaddr-addr.buf,
@@ -260,9 +264,12 @@ svc_tli_create(
 __func__);
 goto freedata;
 			}
-			listen(fd, (int)bindaddr-qlen);
+			if (listen(fd, (int)bindaddr-qlen) == -1) {
+warnx(%s: could not listen at requested 
+address, __func__);
+goto freedata;
+			}
 		}
-			
 	}
 	/*
 	 * call transport specific function.



CVS commit: src/lib/libc/rpc

2014-01-21 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Jan 21 17:39:24 UTC 2014

Modified Files:
src/lib/libc/rpc: clnt_vc.c

Log Message:
Increment to the value, not the pointer. (Thorsten Brehm)


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/lib/libc/rpc/clnt_vc.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/rpc/clnt_vc.c
diff -u src/lib/libc/rpc/clnt_vc.c:1.24 src/lib/libc/rpc/clnt_vc.c:1.25
--- src/lib/libc/rpc/clnt_vc.c:1.24	Thu Oct 17 19:58:05 2013
+++ src/lib/libc/rpc/clnt_vc.c	Tue Jan 21 12:39:24 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: clnt_vc.c,v 1.24 2013/10/17 23:58:05 christos Exp $	*/
+/*	$NetBSD: clnt_vc.c,v 1.25 2014/01/21 17:39:24 christos Exp $	*/
 
 /*
  * Copyright (c) 2010, Oracle America, Inc.
@@ -38,7 +38,7 @@ static char *sccsid = @(#)clnt_tcp.c 1.
 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.24 2013/10/17 23:58:05 christos Exp $);
+__RCSID($NetBSD: clnt_vc.c,v 1.25 2014/01/21 17:39:24 christos Exp $);
 #endif
 #endif
  
@@ -145,16 +145,16 @@ static cond_t   *vc_cv;
 #endif
 
 static __inline void
-htonlp(void *dst, const void *src)
+htonlp(void *dst, const void *src, uint32_t incr)
 {
 #if 0
 	uint32_t tmp;
 	memcpy(tmp, src, sizeof(tmp));
-	tmp = htonl(tmp);
+	tmp = htonl(tmp + incr);
 	memcpy(dst, tmp, sizeof(tmp));
 #else
 	/* We are aligned, so we think */
-	*(uint32_t *)dst = htonl(*(const uint32_t *)src);
+	*(uint32_t *)dst = htonl(*(const uint32_t *)src + incr);
 #endif
 }
 
@@ -609,9 +609,8 @@ clnt_vc_control(
 		break;
 	case CLSET_XID:
 		/* This will set the xid of the NEXT call */
-		htonlp(ct-ct_u.ct_mcalli, (const char *)info +
-		sizeof(uint32_t));
 		/* increment by 1 as clnt_vc_call() decrements once */
+		htonlp(ct-ct_u.ct_mcalli, info, 1);
 		break;
 	case CLGET_VERS:
 		/*
@@ -624,7 +623,7 @@ clnt_vc_control(
 		break;
 
 	case CLSET_VERS:
-		htonlp(ct-ct_u.ct_mcallc + 4 * BYTES_PER_XDR_UNIT, info);
+		htonlp(ct-ct_u.ct_mcallc + 4 * BYTES_PER_XDR_UNIT, info, 0);
 		break;
 
 	case CLGET_PROG:
@@ -638,7 +637,7 @@ clnt_vc_control(
 		break;
 
 	case CLSET_PROG:
-		htonlp(ct-ct_u.ct_mcallc + 3 * BYTES_PER_XDR_UNIT, info);
+		htonlp(ct-ct_u.ct_mcallc + 3 * BYTES_PER_XDR_UNIT, info, 0);
 		break;
 
 	default:



CVS commit: src/lib/libc/rpc

2014-01-02 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Jan  2 20:12:23 UTC 2014

Modified Files:
src/lib/libc/rpc: rpcb_clnt.c

Log Message:
don't lose the RPC error from CLNT_CALL.


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/lib/libc/rpc/rpcb_clnt.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/rpc/rpcb_clnt.c
diff -u src/lib/libc/rpc/rpcb_clnt.c:1.29 src/lib/libc/rpc/rpcb_clnt.c:1.30
--- src/lib/libc/rpc/rpcb_clnt.c:1.29	Mon Mar 11 16:19:29 2013
+++ src/lib/libc/rpc/rpcb_clnt.c	Thu Jan  2 15:12:23 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: rpcb_clnt.c,v 1.29 2013/03/11 20:19:29 tron Exp $	*/
+/*	$NetBSD: rpcb_clnt.c,v 1.30 2014/01/02 20:12:23 christos Exp $	*/
 
 /*
  * Copyright (c) 2010, Oracle America, Inc.
@@ -41,7 +41,7 @@
 #if 0
 static char sccsid[] = @(#)rpcb_clnt.c 1.30 89/06/21 Copyr 1988 Sun Micro;
 #else
-__RCSID($NetBSD: rpcb_clnt.c,v 1.29 2013/03/11 20:19:29 tron Exp $);
+__RCSID($NetBSD: rpcb_clnt.c,v 1.30 2014/01/02 20:12:23 christos Exp $);
 #endif
 #endif
 
@@ -578,9 +578,12 @@ rpcb_set(rpcprog_t program, rpcvers_t ve
 	(void) snprintf(uidbuf, sizeof uidbuf, %d, geteuid());
 	parms.r_owner = uidbuf;
 
-	CLNT_CALL(client, (rpcproc_t)RPCBPROC_SET, (xdrproc_t) xdr_rpcb,
+	if (CLNT_CALL(client, (rpcproc_t)RPCBPROC_SET, (xdrproc_t) xdr_rpcb,
 	(char *)(void *)parms, (xdrproc_t) xdr_bool,
-	(char *)(void *)rslt, tottimeout);
+	(char *)(void *)rslt, tottimeout) != RPC_SUCCESS) {
+		rpc_createerr.cf_stat = RPC_PMAPFAILURE;
+		clnt_geterr(client, rpc_createerr.cf_error);
+	}
 
 	CLNT_DESTROY(client);
 	free(parms.r_addr);
@@ -617,9 +620,12 @@ rpcb_unset(rpcprog_t program, rpcvers_t 
 	(void) snprintf(uidbuf, sizeof uidbuf, %d, geteuid());
 	parms.r_owner = uidbuf;
 
-	CLNT_CALL(client, (rpcproc_t)RPCBPROC_UNSET, (xdrproc_t) xdr_rpcb,
+	if (CLNT_CALL(client, (rpcproc_t)RPCBPROC_UNSET, (xdrproc_t) xdr_rpcb,
 	(char *)(void *)parms, (xdrproc_t) xdr_bool,
-	(char *)(void *)rslt, tottimeout);
+	(char *)(void *)rslt, tottimeout) != RPC_SUCCESS) {
+		rpc_createerr.cf_stat = RPC_PMAPFAILURE;
+		clnt_geterr(client, rpc_createerr.cf_error);
+	}
 
 	CLNT_DESTROY(client);
 	return (rslt);
@@ -1218,9 +1224,13 @@ rpcb_taddr2uaddr(struct netconfig *nconf
 		return (NULL);
 	}
 
-	CLNT_CALL(client, (rpcproc_t)RPCBPROC_TADDR2UADDR,
+	if (CLNT_CALL(client, (rpcproc_t)RPCBPROC_TADDR2UADDR,
 	(xdrproc_t) xdr_netbuf, (char *)(void *)taddr,
-	(xdrproc_t) xdr_wrapstring, (char *)(void *)uaddr, tottimeout);
+	(xdrproc_t) xdr_wrapstring, (char *)(void *)uaddr, tottimeout) 
+	!= RPC_SUCCESS) {
+		rpc_createerr.cf_stat = RPC_PMAPFAILURE;
+		clnt_geterr(client, rpc_createerr.cf_error);
+	}
 	CLNT_DESTROY(client);
 	return (uaddr);
 }
@@ -1259,6 +1269,8 @@ rpcb_uaddr2taddr(struct netconfig *nconf
 	(xdrproc_t) xdr_wrapstring, (char *)(void *)uaddr,
 	(xdrproc_t) xdr_netbuf, (char *)(void *)taddr,
 	tottimeout) != RPC_SUCCESS) {
+		rpc_createerr.cf_stat = RPC_PMAPFAILURE;
+		clnt_geterr(client, rpc_createerr.cf_error);
 		free(taddr);
 		taddr = NULL;
 	}



CVS commit: src/lib/libc/rpc

2013-10-17 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Oct 17 23:58:05 UTC 2013

Modified Files:
src/lib/libc/rpc: clnt_vc.c

Log Message:
Avoid casting gymnastics that lead to pointer aliasing by introducing an
inline function.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/lib/libc/rpc/clnt_vc.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/rpc/clnt_vc.c
diff -u src/lib/libc/rpc/clnt_vc.c:1.23 src/lib/libc/rpc/clnt_vc.c:1.24
--- src/lib/libc/rpc/clnt_vc.c:1.23	Tue May  7 17:08:45 2013
+++ src/lib/libc/rpc/clnt_vc.c	Thu Oct 17 19:58:05 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: clnt_vc.c,v 1.23 2013/05/07 21:08:45 christos Exp $	*/
+/*	$NetBSD: clnt_vc.c,v 1.24 2013/10/17 23:58:05 christos Exp $	*/
 
 /*
  * Copyright (c) 2010, Oracle America, Inc.
@@ -38,7 +38,7 @@ static char *sccsid = @(#)clnt_tcp.c 1.
 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.23 2013/05/07 21:08:45 christos Exp $);
+__RCSID($NetBSD: clnt_vc.c,v 1.24 2013/10/17 23:58:05 christos Exp $);
 #endif
 #endif
  
@@ -144,6 +144,33 @@ static cond_t   *vc_cv;
 #define __rpc_lock_value 0
 #endif
 
+static __inline void
+htonlp(void *dst, const void *src)
+{
+#if 0
+	uint32_t tmp;
+	memcpy(tmp, src, sizeof(tmp));
+	tmp = htonl(tmp);
+	memcpy(dst, tmp, sizeof(tmp));
+#else
+	/* We are aligned, so we think */
+	*(uint32_t *)dst = htonl(*(const uint32_t *)src);
+#endif
+}
+
+static __inline void
+ntohlp(void *dst, const void *src)
+{
+#if 0
+	uint32_t tmp;
+	memcpy(tmp, src, sizeof(tmp));
+	tmp = ntohl(tmp);
+	memcpy(dst, tmp, sizeof(tmp));
+#else
+	/* We are aligned, so we think */
+	*(uint32_t *)dst = htonl(*(const uint32_t *)src);
+#endif
+}
 
 /*
  * Create a client handle for a connection.
@@ -578,13 +605,12 @@ clnt_vc_control(
 		 * first element in the call structure
 		 * This will get the xid of the PREVIOUS call
 		 */
-		*(u_int32_t *)(void *)info =
-		ntohl(*(u_int32_t *)(void *)ct-ct_u.ct_mcalli);
+		ntohlp(info, ct-ct_u.ct_mcalli);
 		break;
 	case CLSET_XID:
 		/* This will set the xid of the NEXT call */
-		*(u_int32_t *)(void *)ct-ct_u.ct_mcalli =
-		htonl(*((u_int32_t *)(void *)info) + 1);
+		htonlp(ct-ct_u.ct_mcalli, (const char *)info +
+		sizeof(uint32_t));
 		/* increment by 1 as clnt_vc_call() decrements once */
 		break;
 	case CLGET_VERS:
@@ -594,15 +620,11 @@ clnt_vc_control(
 		 * begining of the RPC header. MUST be changed if the
 		 * call_struct is changed
 		 */
-		*(u_int32_t *)(void *)info =
-		ntohl(*(u_int32_t *)(void *)(ct-ct_u.ct_mcallc +
-		4 * BYTES_PER_XDR_UNIT));
+		ntohlp(info, ct-ct_u.ct_mcallc + 4 * BYTES_PER_XDR_UNIT);
 		break;
 
 	case CLSET_VERS:
-		*(u_int32_t *)(void *)(ct-ct_u.ct_mcallc +
-		4 * BYTES_PER_XDR_UNIT) =
-		htonl(*(u_int32_t *)(void *)info);
+		htonlp(ct-ct_u.ct_mcallc + 4 * BYTES_PER_XDR_UNIT, info);
 		break;
 
 	case CLGET_PROG:
@@ -612,15 +634,11 @@ clnt_vc_control(
 		 * begining of the RPC header. MUST be changed if the
 		 * call_struct is changed
 		 */
-		*(u_int32_t *)(void *)info =
-		ntohl(*(u_int32_t *)(void *)(ct-ct_u.ct_mcallc +
-		3 * BYTES_PER_XDR_UNIT));
+		ntohlp(info, ct-ct_u.ct_mcallc + 3 * BYTES_PER_XDR_UNIT);
 		break;
 
 	case CLSET_PROG:
-		*(u_int32_t *)(void *)(ct-ct_u.ct_mcallc +
-		3 * BYTES_PER_XDR_UNIT) =
-		htonl(*(u_int32_t *)(void *)info);
+		htonlp(ct-ct_u.ct_mcallc + 3 * BYTES_PER_XDR_UNIT, info);
 		break;
 
 	default:



CVS commit: src/lib/libc/rpc

2013-05-07 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue May  7 21:08:45 UTC 2013

Modified Files:
src/lib/libc/rpc: clnt_dg.c clnt_generic.c clnt_vc.c rpc_internal.h

Log Message:
- add __clnt_sigfillset() that does not blindly block all signals but excludes
  the tty generated ones (int, quit, tstp), plus term and hup. This makes
  command line clients behave on connect(2) where before they would need
  to be killed from a different tty. Much easier than making the file
  descriptor non-blocking for the duration of connect and then using
  pselect/pollts to detect when actual connection or timeout occured using
  a different sigmask.
- factor out some of the error paths.


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/lib/libc/rpc/clnt_dg.c
cvs rdiff -u -r1.30 -r1.31 src/lib/libc/rpc/clnt_generic.c
cvs rdiff -u -r1.22 -r1.23 src/lib/libc/rpc/clnt_vc.c
cvs rdiff -u -r1.6 -r1.7 src/lib/libc/rpc/rpc_internal.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/rpc/clnt_dg.c
diff -u src/lib/libc/rpc/clnt_dg.c:1.28 src/lib/libc/rpc/clnt_dg.c:1.29
--- src/lib/libc/rpc/clnt_dg.c:1.28	Mon Mar 11 16:19:28 2013
+++ src/lib/libc/rpc/clnt_dg.c	Tue May  7 17:08:44 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: clnt_dg.c,v 1.28 2013/03/11 20:19:28 tron Exp $	*/
+/*	$NetBSD: clnt_dg.c,v 1.29 2013/05/07 21:08:44 christos Exp $	*/
 
 /*
  * Copyright (c) 2010, Oracle America, Inc.
@@ -41,7 +41,7 @@
 #if 0
 static char sccsid[] = @(#)clnt_dg.c 1.19 89/03/16 Copyr 1988 Sun Micro;
 #else
-__RCSID($NetBSD: clnt_dg.c,v 1.28 2013/03/11 20:19:28 tron Exp $);
+__RCSID($NetBSD: clnt_dg.c,v 1.29 2013/05/07 21:08:44 christos Exp $);
 #endif
 #endif
 
@@ -175,7 +175,7 @@ clnt_dg_create(
 	struct __rpc_sockinfo si;
 	int one = 1;
 
-	sigfillset(newmask);
+	__clnt_sigfillset(newmask);
 	thr_sigsetmask(SIG_SETMASK, newmask, mask);
 	mutex_lock(clnt_fd_lock);
 	if (dg_fd_locks == NULL) {
@@ -188,9 +188,7 @@ clnt_dg_create(
 		fd_allocsz = dtbsize * sizeof (int);
 		dg_fd_locks = mem_alloc(fd_allocsz);
 		if (dg_fd_locks == NULL) {
-			mutex_unlock(clnt_fd_lock);
-			thr_sigsetmask(SIG_SETMASK, (mask), NULL);
-			goto err1;
+			goto err0;
 		} else
 			memset(dg_fd_locks, '\0', fd_allocsz);
 
@@ -200,9 +198,7 @@ clnt_dg_create(
 		if (dg_cv == NULL) {
 			mem_free(dg_fd_locks, fd_allocsz);
 			dg_fd_locks = NULL;
-			mutex_unlock(clnt_fd_lock);
-			thr_sigsetmask(SIG_SETMASK, (mask), NULL);
-			goto err1;
+			goto err0;
 		} else {
 			int i;
 
@@ -294,6 +290,9 @@ clnt_dg_create(
 	cl-cl_tp = NULL;
 	cl-cl_netid = NULL;
 	return (cl);
+err0:
+	mutex_unlock(clnt_fd_lock);
+	thr_sigsetmask(SIG_SETMASK, (mask), NULL);
 err1:
 	warnx(mem_err_clnt_dg);
 	rpc_createerr.cf_stat = RPC_SYSTEMERROR;
@@ -341,7 +340,7 @@ clnt_dg_call(
 
 	cu = (struct cu_data *)cl-cl_private;
 
-	sigfillset(newmask);
+	__clnt_sigfillset(newmask);
 	thr_sigsetmask(SIG_SETMASK, newmask, mask);
 	mutex_lock(clnt_fd_lock);
 	while (dg_fd_locks[cu-cu_fd])
@@ -532,7 +531,7 @@ clnt_dg_freeres(CLIENT *cl, xdrproc_t xd
 	cu = (struct cu_data *)cl-cl_private;
 	xdrs = (cu-cu_outxdrs);
 
-	sigfillset(newmask);
+	__clnt_sigfillset(newmask);
 	thr_sigsetmask(SIG_SETMASK, newmask, mask);
 	mutex_lock(clnt_fd_lock);
 	while (dg_fd_locks[cu-cu_fd])
@@ -566,7 +565,7 @@ clnt_dg_control(CLIENT *cl, u_int reques
 
 	cu = (struct cu_data *)cl-cl_private;
 
-	sigfillset(newmask);
+	__clnt_sigfillset(newmask);
 	thr_sigsetmask(SIG_SETMASK, newmask, mask);
 	mutex_lock(clnt_fd_lock);
 	while (dg_fd_locks[cu-cu_fd])
@@ -706,7 +705,7 @@ clnt_dg_destroy(CLIENT *cl)
 	cu = (struct cu_data *)cl-cl_private;
 	cu_fd = cu-cu_fd;
 
-	sigfillset(newmask);
+	__clnt_sigfillset(newmask);
 	thr_sigsetmask(SIG_SETMASK, newmask, mask);
 	mutex_lock(clnt_fd_lock);
 	while (dg_fd_locks[cu_fd])
@@ -737,7 +736,7 @@ clnt_dg_ops(void)
 
 /* VARIABLES PROTECTED BY ops_lock: ops */
 
-	sigfillset(newmask);
+	__clnt_sigfillset(newmask);
 	thr_sigsetmask(SIG_SETMASK, newmask, mask);
 	mutex_lock(ops_lock);
 	if (ops.cl_call == NULL) {

Index: src/lib/libc/rpc/clnt_generic.c
diff -u src/lib/libc/rpc/clnt_generic.c:1.30 src/lib/libc/rpc/clnt_generic.c:1.31
--- src/lib/libc/rpc/clnt_generic.c:1.30	Mon Mar 11 16:19:28 2013
+++ src/lib/libc/rpc/clnt_generic.c	Tue May  7 17:08:45 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: clnt_generic.c,v 1.30 2013/03/11 20:19:28 tron Exp $	*/
+/*	$NetBSD: clnt_generic.c,v 1.31 2013/05/07 21:08:45 christos Exp $	*/
 
 /*
  * Copyright (c) 2010, Oracle America, Inc.
@@ -41,7 +41,7 @@
 #if 0
 static char sccsid[] = @(#)clnt_generic.c 1.32 89/03/16 Copyr 1988 Sun Micro;
 #else
-__RCSID($NetBSD: clnt_generic.c,v 1.30 2013/03/11 20:19:28 tron Exp $);
+__RCSID($NetBSD: clnt_generic.c,v 1.31 2013/05/07 21:08:45 christos Exp $);
 #endif
 #endif
 
@@ -381,3 +381,20 @@ err1:	if (madefd)
 		(void) close(fd);
 	return (NULL);
 }
+
+/*
+ * Don't block thse so interactive programs don't 

CVS commit: src/lib/libc/rpc

2013-04-17 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Apr 17 16:36:47 UTC 2013

Modified Files:
src/lib/libc/rpc: clnt_vc.c

Log Message:
PR/47747: Thorsten Brehm: TCP-based RPC client calls no longer terminate when
connections break. Return proper error code.
XXX: pullup 6


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/lib/libc/rpc/clnt_vc.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/rpc/clnt_vc.c
diff -u src/lib/libc/rpc/clnt_vc.c:1.21 src/lib/libc/rpc/clnt_vc.c:1.22
--- src/lib/libc/rpc/clnt_vc.c:1.21	Mon Mar 11 16:19:29 2013
+++ src/lib/libc/rpc/clnt_vc.c	Wed Apr 17 12:36:47 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: clnt_vc.c,v 1.21 2013/03/11 20:19:29 tron Exp $	*/
+/*	$NetBSD: clnt_vc.c,v 1.22 2013/04/17 16:36:47 christos Exp $	*/
 
 /*
  * Copyright (c) 2010, Oracle America, Inc.
@@ -38,7 +38,7 @@ static char *sccsid = @(#)clnt_tcp.c 1.
 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.21 2013/03/11 20:19:29 tron Exp $);
+__RCSID($NetBSD: clnt_vc.c,v 1.22 2013/04/17 16:36:47 christos Exp $);
 #endif
 #endif
  
@@ -713,7 +713,7 @@ read_vc(char *ctp, char *buf, int len)
 		/* premature eof */
 		ct-ct_error.re_errno = ECONNRESET;
 		ct-ct_error.re_status = RPC_CANTRECV;
-		len = -1;  /* it's really an error */
+		nread = -1;  /* it's really an error */
 		break;
 
 	case -1:



CVS commit: src/lib/libc/rpc

2013-04-04 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Fri Apr  5 03:17:38 UTC 2013

Modified Files:
src/lib/libc/rpc: rpc_generic.c

Log Message:
stdlib.h, not malloc.h


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/lib/libc/rpc/rpc_generic.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/rpc/rpc_generic.c
diff -u src/lib/libc/rpc/rpc_generic.c:1.28 src/lib/libc/rpc/rpc_generic.c:1.29
--- src/lib/libc/rpc/rpc_generic.c:1.28	Mon Mar 11 20:19:29 2013
+++ src/lib/libc/rpc/rpc_generic.c	Fri Apr  5 03:17:38 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: rpc_generic.c,v 1.28 2013/03/11 20:19:29 tron Exp $	*/
+/*	$NetBSD: rpc_generic.c,v 1.29 2013/04/05 03:17:38 dholland Exp $	*/
 
 /*
  * Copyright (c) 2010, Oracle America, Inc.
@@ -43,7 +43,7 @@
 
 #include sys/cdefs.h
 #if defined(LIBC_SCCS)  !defined(lint)
-__RCSID($NetBSD: rpc_generic.c,v 1.28 2013/03/11 20:19:29 tron Exp $);
+__RCSID($NetBSD: rpc_generic.c,v 1.29 2013/04/05 03:17:38 dholland Exp $);
 #endif
 
 #include namespace.h
@@ -62,7 +62,7 @@ __RCSID($NetBSD: rpc_generic.c,v 1.28 2
 #include stdio.h
 #include netdb.h
 #include netconfig.h
-#include malloc.h
+#include stdlib.h
 #include string.h
 #include syslog.h
 #include rpc/nettype.h



CVS commit: src/lib/libc/rpc

2013-03-05 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Mar  5 19:55:23 UTC 2013

Modified Files:
src/lib/libc/rpc: bindresvport.c clnt_bcast.c clnt_dg.c clnt_generic.c
clnt_vc.c rpc_generic.c rpc_soc.c rpcb_clnt.c svc.c svc_dg.c
svc_generic.c svc_run.c svc_vc.c
Added Files:
src/lib/libc/rpc: svc_fdset.c svc_fdset.h

Log Message:
make this usable from RUMP


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/lib/libc/rpc/bindresvport.c
cvs rdiff -u -r1.24 -r1.25 src/lib/libc/rpc/clnt_bcast.c
cvs rdiff -u -r1.26 -r1.27 src/lib/libc/rpc/clnt_dg.c \
src/lib/libc/rpc/rpc_generic.c
cvs rdiff -u -r1.28 -r1.29 src/lib/libc/rpc/clnt_generic.c \
src/lib/libc/rpc/svc_vc.c
cvs rdiff -u -r1.19 -r1.20 src/lib/libc/rpc/clnt_vc.c
cvs rdiff -u -r1.16 -r1.17 src/lib/libc/rpc/rpc_soc.c
cvs rdiff -u -r1.27 -r1.28 src/lib/libc/rpc/rpcb_clnt.c
cvs rdiff -u -r1.32 -r1.33 src/lib/libc/rpc/svc.c
cvs rdiff -u -r1.15 -r1.16 src/lib/libc/rpc/svc_dg.c
cvs rdiff -u -r0 -r1.1 src/lib/libc/rpc/svc_fdset.c \
src/lib/libc/rpc/svc_fdset.h
cvs rdiff -u -r1.13 -r1.14 src/lib/libc/rpc/svc_generic.c
cvs rdiff -u -r1.20 -r1.21 src/lib/libc/rpc/svc_run.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/rpc/bindresvport.c
diff -u src/lib/libc/rpc/bindresvport.c:1.23 src/lib/libc/rpc/bindresvport.c:1.24
--- src/lib/libc/rpc/bindresvport.c:1.23	Tue Mar 20 13:14:50 2012
+++ src/lib/libc/rpc/bindresvport.c	Tue Mar  5 14:55:22 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: bindresvport.c,v 1.23 2012/03/20 17:14:50 matt Exp $	*/
+/*	$NetBSD: bindresvport.c,v 1.24 2013/03/05 19:55:22 christos Exp $	*/
 
 /*
  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
@@ -35,7 +35,7 @@
 static char *sccsid = @(#)bindresvport.c 1.8 88/02/08 SMI;
 static char *sccsid = @(#)bindresvport.c	2.2 88/07/29 4.0 RPCSRC;
 #else
-__RCSID($NetBSD: bindresvport.c,v 1.23 2012/03/20 17:14:50 matt Exp $);
+__RCSID($NetBSD: bindresvport.c,v 1.24 2013/03/05 19:55:22 christos Exp $);
 #endif
 #endif
 
@@ -55,6 +55,7 @@ __RCSID($NetBSD: bindresvport.c,v 1.23 
 #include unistd.h
 
 #include rpc/rpc.h
+#include svc_fdset.h
 
 #ifdef __weak_alias
 __weak_alias(bindresvport,_bindresvport)

Index: src/lib/libc/rpc/clnt_bcast.c
diff -u src/lib/libc/rpc/clnt_bcast.c:1.24 src/lib/libc/rpc/clnt_bcast.c:1.25
--- src/lib/libc/rpc/clnt_bcast.c:1.24	Tue Mar 20 13:14:50 2012
+++ src/lib/libc/rpc/clnt_bcast.c	Tue Mar  5 14:55:22 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: clnt_bcast.c,v 1.24 2012/03/20 17:14:50 matt Exp $	*/
+/*	$NetBSD: clnt_bcast.c,v 1.25 2013/03/05 19:55:22 christos Exp $	*/
 
 /*
  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
@@ -39,7 +39,7 @@
 #if 0
 static char sccsid[] = @(#)clnt_bcast.c 1.15 89/04/21 Copyr 1988 Sun Micro;
 #else
-__RCSID($NetBSD: clnt_bcast.c,v 1.24 2012/03/20 17:14:50 matt Exp $);
+__RCSID($NetBSD: clnt_bcast.c,v 1.25 2013/03/05 19:55:22 christos Exp $);
 #endif
 #endif
 
@@ -81,6 +81,7 @@ __RCSID($NetBSD: clnt_bcast.c,v 1.24 20
 #include string.h
 
 #include rpc_internal.h
+#include svc_fdset.h
 
 #define	MAXBCAST 20	/* Max no of broadcasting transports */
 #define	INITTIME 4000	/* Time to wait initially */

Index: src/lib/libc/rpc/clnt_dg.c
diff -u src/lib/libc/rpc/clnt_dg.c:1.26 src/lib/libc/rpc/clnt_dg.c:1.27
--- src/lib/libc/rpc/clnt_dg.c:1.26	Tue Mar 20 13:14:50 2012
+++ src/lib/libc/rpc/clnt_dg.c	Tue Mar  5 14:55:22 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: clnt_dg.c,v 1.26 2012/03/20 17:14:50 matt Exp $	*/
+/*	$NetBSD: clnt_dg.c,v 1.27 2013/03/05 19:55:22 christos Exp $	*/
 
 /*
  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
@@ -39,7 +39,7 @@
 #if 0
 static char sccsid[] = @(#)clnt_dg.c 1.19 89/03/16 Copyr 1988 Sun Micro;
 #else
-__RCSID($NetBSD: clnt_dg.c,v 1.26 2012/03/20 17:14:50 matt Exp $);
+__RCSID($NetBSD: clnt_dg.c,v 1.27 2013/03/05 19:55:22 christos Exp $);
 #endif
 #endif
 
@@ -62,6 +62,8 @@ __RCSID($NetBSD: clnt_dg.c,v 1.26 2012/
 #include signal.h
 #include unistd.h
 #include err.h
+
+#include svc_fdset.h
 #include rpc_internal.h
 
 #ifdef __weak_alias
@@ -247,8 +249,13 @@ clnt_dg_create(
 	cu-cu_rlen = svcaddr-len;
 	cu-cu_outbuf = cu-cu_inbuf[recvsz];
 	/* Other values can also be set through clnt_control() */
+#ifdef RUMP_RPC
 	cu-cu_wait.tv_sec = 15;	/* heuristically chosen */
 	cu-cu_wait.tv_usec = 0;
+#else
+	cu-cu_wait.tv_sec = 0;		/* for testing, 10x / second */
+	cu-cu_wait.tv_usec = 10;
+#endif
 	cu-cu_total.tv_sec = -1;
 	cu-cu_total.tv_usec = -1;
 	cu-cu_sendsz = sendsz;
Index: src/lib/libc/rpc/rpc_generic.c
diff -u src/lib/libc/rpc/rpc_generic.c:1.26 src/lib/libc/rpc/rpc_generic.c:1.27
--- src/lib/libc/rpc/rpc_generic.c:1.26	Tue Mar 20 13:14:50 2012
+++ src/lib/libc/rpc/rpc_generic.c	Tue Mar  5 14:55:22 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: rpc_generic.c,v 1.26 2012/03/20 17:14:50 matt Exp $	*/
+/*	$NetBSD: 

CVS commit: src/lib/libc/rpc

2013-03-04 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Mar  4 17:17:57 UTC 2013

Modified Files:
src/lib/libc/rpc: auth_unix.c clnt_raw.c svc_generic.c svc_simple.c
svc_vc.c xdr.c xdr_array.c xdr_rec.c xdr_reference.c

Log Message:
fix error messages and warnings.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/lib/libc/rpc/auth_unix.c
cvs rdiff -u -r1.30 -r1.31 src/lib/libc/rpc/clnt_raw.c
cvs rdiff -u -r1.12 -r1.13 src/lib/libc/rpc/svc_generic.c
cvs rdiff -u -r1.31 -r1.32 src/lib/libc/rpc/svc_simple.c \
src/lib/libc/rpc/xdr.c
cvs rdiff -u -r1.26 -r1.27 src/lib/libc/rpc/svc_vc.c
cvs rdiff -u -r1.17 -r1.18 src/lib/libc/rpc/xdr_array.c
cvs rdiff -u -r1.33 -r1.34 src/lib/libc/rpc/xdr_rec.c
cvs rdiff -u -r1.16 -r1.17 src/lib/libc/rpc/xdr_reference.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/rpc/auth_unix.c
diff -u src/lib/libc/rpc/auth_unix.c:1.23 src/lib/libc/rpc/auth_unix.c:1.24
--- src/lib/libc/rpc/auth_unix.c:1.23	Tue Mar 20 13:14:50 2012
+++ src/lib/libc/rpc/auth_unix.c	Mon Mar  4 12:17:56 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: auth_unix.c,v 1.23 2012/03/20 17:14:50 matt Exp $	*/
+/*	$NetBSD: auth_unix.c,v 1.24 2013/03/04 17:17:56 christos Exp $	*/
 
 /*
  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
@@ -35,7 +35,7 @@
 static char *sccsid = @(#)auth_unix.c 1.19 87/08/11 Copyr 1984 Sun Micro;
 static char *sccsid = @(#)auth_unix.c	2.2 88/08/01 4.0 RPCSRC;
 #else
-__RCSID($NetBSD: auth_unix.c,v 1.23 2012/03/20 17:14:50 matt Exp $);
+__RCSID($NetBSD: auth_unix.c,v 1.24 2013/03/04 17:17:56 christos Exp $);
 #endif
 #endif
 
@@ -115,14 +115,14 @@ authunix_create(char *machname, int uid,
 	auth = mem_alloc(sizeof(*auth));
 #ifndef KERNEL
 	if (auth == NULL) {
-		warnx(authunix_create: out of memory);
+		warn(%s: out of memory, __func__);
 		goto cleanup_authunix_create;
 	}
 #endif
 	au = mem_alloc(sizeof(*au));
 #ifndef KERNEL
 	if (au == NULL) {
-		warnx(authunix_create: out of memory);
+		warn(%s: out of memory, __func__);
 		goto cleanup_authunix_create;
 	}
 #endif
@@ -155,7 +155,7 @@ authunix_create(char *machname, int uid,
 	au-au_origcred.oa_base = mem_alloc((size_t)len);
 #else
 	if ((au-au_origcred.oa_base = mem_alloc((size_t)len)) == NULL) {
-		warnx(authunix_create: out of memory);
+		warn(%s: out of memory, __func__);
 		goto cleanup_authunix_create;
 	}
 #endif
@@ -342,7 +342,7 @@ marshal_new_auth(AUTH *auth)
 	xdrmem_create(xdrs, au-au_marshed, MAX_AUTH_BYTES, XDR_ENCODE);
 	if ((! xdr_opaque_auth(xdrs, (auth-ah_cred))) ||
 	(! xdr_opaque_auth(xdrs, (auth-ah_verf
-		warnx(auth_none.c - Fatal marshalling problem);
+		warnx(%s: Fatal marshalling problem, __func__);
 	else
 		au-au_mpos = XDR_GETPOS(xdrs);
 	XDR_DESTROY(xdrs);

Index: src/lib/libc/rpc/clnt_raw.c
diff -u src/lib/libc/rpc/clnt_raw.c:1.30 src/lib/libc/rpc/clnt_raw.c:1.31
--- src/lib/libc/rpc/clnt_raw.c:1.30	Tue Mar 20 13:14:50 2012
+++ src/lib/libc/rpc/clnt_raw.c	Mon Mar  4 12:17:56 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: clnt_raw.c,v 1.30 2012/03/20 17:14:50 matt Exp $	*/
+/*	$NetBSD: clnt_raw.c,v 1.31 2013/03/04 17:17:56 christos Exp $	*/
 
 /*
  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
@@ -35,7 +35,7 @@
 static char *sccsid = @(#)clnt_raw.c 1.22 87/08/11 Copyr 1984 Sun Micro;
 static char *sccsid = @(#)clnt_raw.c	2.2 88/08/01 4.0 RPCSRC;
 #else
-__RCSID($NetBSD: clnt_raw.c,v 1.30 2012/03/20 17:14:50 matt Exp $);
+__RCSID($NetBSD: clnt_raw.c,v 1.31 2013/03/04 17:17:56 christos Exp $);
 #endif
 #endif
 
@@ -128,7 +128,7 @@ clnt_raw_create(rpcprog_t prog, rpcvers_
 	call_msg.rm_call.cb_vers = (u_int32_t)vers;
 	xdrmem_create(xdrs, clp-u.mashl_callmsg, MCALL_MSG_SIZE, XDR_ENCODE); 
 	if (! xdr_callhdr(xdrs, call_msg))
-		warnx(clntraw_create - Fatal header serialization error.);
+		warnx(%s: Fatal header serialization error, __func__);
 	clp-mcnt = XDR_GETPOS(xdrs);
 	XDR_DESTROY(xdrs);
 

Index: src/lib/libc/rpc/svc_generic.c
diff -u src/lib/libc/rpc/svc_generic.c:1.12 src/lib/libc/rpc/svc_generic.c:1.13
--- src/lib/libc/rpc/svc_generic.c:1.12	Tue Mar 20 13:14:50 2012
+++ src/lib/libc/rpc/svc_generic.c	Mon Mar  4 12:17:56 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: svc_generic.c,v 1.12 2012/03/20 17:14:50 matt Exp $	*/
+/*	$NetBSD: svc_generic.c,v 1.13 2013/03/04 17:17:56 christos Exp $	*/
 
 /*
  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
@@ -40,7 +40,7 @@
 #if 0
 static char sccsid[] = @(#)svc_generic.c 1.21 89/02/28 Copyr 1988 Sun Micro;
 #else
-__RCSID($NetBSD: svc_generic.c,v 1.12 2012/03/20 17:14:50 matt Exp $);
+__RCSID($NetBSD: svc_generic.c,v 1.13 2013/03/04 17:17:56 christos Exp $);
 #endif
 #endif
 
@@ -105,7 +105,7 @@ svc_create(
 /* VARIABLES PROTECTED BY xprtlist_lock: xprtlist */
 
 	if ((handle = __rpc_setconf(nettype)) == NULL) {
-		warnx(svc_create: unknown protocol);
+		warnx(%s: unknown 

CVS commit: src/lib/libc/rpc

2013-02-26 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Feb 26 16:33:57 UTC 2013

Modified Files:
src/lib/libc/rpc: clnt_vc.c

Log Message:
PR/13082: Thorsten Brehm: Fix wrong memcpy that caused possible memory
corruption. XXX: pullup to 6.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/lib/libc/rpc/clnt_vc.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/rpc/clnt_vc.c
diff -u src/lib/libc/rpc/clnt_vc.c:1.18 src/lib/libc/rpc/clnt_vc.c:1.19
--- src/lib/libc/rpc/clnt_vc.c:1.18	Tue Mar 13 17:13:44 2012
+++ src/lib/libc/rpc/clnt_vc.c	Tue Feb 26 11:33:57 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: clnt_vc.c,v 1.18 2012/03/13 21:13:44 christos Exp $	*/
+/*	$NetBSD: clnt_vc.c,v 1.19 2013/02/26 16:33:57 christos 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.
 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.18 2012/03/13 21:13:44 christos Exp $);
+__RCSID($NetBSD: clnt_vc.c,v 1.19 2013/02/26 16:33:57 christos Exp $);
 #endif
 #endif
  
@@ -263,8 +263,8 @@ clnt_vc_create(
 	ct-ct_addr.buf = malloc((size_t)raddr-maxlen);
 	if (ct-ct_addr.buf == NULL)
 		goto fooy;
-	memcpy(ct-ct_addr.buf, raddr-buf, (size_t)raddr-len);
-	ct-ct_addr.len = raddr-maxlen;
+	memcpy(ct-ct_addr.buf, raddr-buf, (size_t)raddr-len);
+	ct-ct_addr.len = raddr-len;
 	ct-ct_addr.maxlen = raddr-maxlen;
 
 	/*



CVS commit: src/lib/libc/rpc

2012-05-13 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Sun May 13 15:47:38 UTC 2012

Modified Files:
src/lib/libc/rpc: rpc.3

Log Message:
Remove unneeded commas in table.
From Bug Hunting.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/lib/libc/rpc/rpc.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/rpc/rpc.3
diff -u src/lib/libc/rpc/rpc.3:1.23 src/lib/libc/rpc/rpc.3:1.24
--- src/lib/libc/rpc/rpc.3:1.23	Tue Aug 30 17:09:52 2011
+++ src/lib/libc/rpc/rpc.3	Sun May 13 15:47:38 2012
@@ -1,6 +1,6 @@
 .\ @(#)rpc.3n 1.31 93/08/31 SMI; from SVr4
 .\ Copyright 1989 ATT
-.\	$NetBSD: rpc.3,v 1.23 2011/08/30 17:09:52 plunky Exp $
+.\	$NetBSD: rpc.3,v 1.24 2012/05/13 15:47:38 wiz Exp $
 .Dd May 7, 1993
 .Dt RPC 3
 .Os
@@ -311,92 +311,92 @@ pages on which they are described:
 .Bl -column authunix_create_default() rpc_clnt_create(3)
 .It Em RPC Routine Ta Em Manual Reference Page
 .Pp
-.It Fn auth_destroy Ta Xr rpc_clnt_auth 3 ,
-.It Fn authdes_create Ta Xr rpc_soc 3 ,
-.It Fn authnone_create Ta Xr rpc_clnt_auth 3 ,
-.It Fn authsys_create Ta Xr rpc_clnt_auth 3 ,
-.It Fn authsys_create_default Ta Xr rpc_clnt_auth 3 ,
-.It Fn authunix_create Ta Xr rpc_soc 3 ,
-.It Fn authunix_create_default Ta Xr rpc_soc 3 ,
-.It Fn callrpc Ta Xr rpc_soc 3 ,
-.It Fn clnt_broadcast Ta Xr rpc_soc 3 ,
-.It Fn clnt_call Ta Xr rpc_clnt_calls 3 ,
-.It Fn clnt_control Ta Xr rpc_clnt_create 3 ,
-.It Fn clnt_create Ta Xr rpc_clnt_create 3 ,
-.It Fn clnt_destroy Ta Xr rpc_clnt_create 3 ,
-.It Fn clnt_dg_create Ta Xr rpc_clnt_create 3 ,
-.It Fn clnt_freeres Ta Xr rpc_clnt_calls 3 ,
-.It Fn clnt_geterr Ta Xr rpc_clnt_calls 3 ,
-.It Fn clnt_pcreateerror Ta Xr rpc_clnt_create 3 ,
-.It Fn clnt_perrno Ta Xr rpc_clnt_calls 3 ,
-.It Fn clnt_perror Ta Xr rpc_clnt_calls 3 ,
-.It Fn clnt_raw_create Ta Xr rpc_clnt_create 3 ,
-.It Fn clnt_spcreateerror Ta Xr rpc_clnt_create 3 ,
-.It Fn clnt_sperrno Ta Xr rpc_clnt_calls 3 ,
-.It Fn clnt_sperror Ta Xr rpc_clnt_calls 3 ,
-.It Fn clnt_tli_create Ta Xr rpc_clnt_create 3 ,
-.It Fn clnt_tp_create Ta Xr rpc_clnt_create 3 ,
-.It Fn clnt_udpcreate Ta Xr rpc_soc 3 ,
-.It Fn clnt_vc_create Ta Xr rpc_clnt_create 3 ,
-.It Fn clntraw_create Ta Xr rpc_soc 3 ,
-.It Fn clnttcp_create Ta Xr rpc_soc 3 ,
-.It Fn clntudp_bufcreate Ta Xr rpc_soc 3 ,
-.It Fn get_myaddress Ta Xr rpc_soc 3 ,
-.It Fn pmap_getmaps Ta Xr rpc_soc 3 ,
-.It Fn pmap_getport Ta Xr rpc_soc 3 ,
-.It Fn pmap_rmtcall Ta Xr rpc_soc 3 ,
-.It Fn pmap_set Ta Xr rpc_soc 3 ,
-.It Fn pmap_unset Ta Xr rpc_soc 3 ,
-.It Fn registerrpc Ta Xr rpc_soc 3 ,
-.It Fn rpc_broadcast Ta Xr rpc_clnt_calls 3 ,
-.It Fn rpc_broadcast_exp Ta Xr rpc_clnt_calls 3 ,
-.It Fn rpc_call Ta Xr rpc_clnt_calls 3 ,
-.It Fn rpc_reg Ta Xr rpc_svc_calls 3 ,
-.It Fn svc_create Ta Xr rpc_svc_create 3 ,
-.It Fn svc_destroy Ta Xr rpc_svc_create 3 ,
-.It Fn svc_dg_create Ta Xr rpc_svc_create 3 ,
-.It Fn svc_dg_enablecache Ta Xr rpc_svc_calls 3 ,
-.It Fn svc_fd_create Ta Xr rpc_svc_create 3 ,
-.It Fn svc_fds Ta Xr rpc_soc 3 ,
-.It Fn svc_freeargs Ta Xr rpc_svc_reg 3 ,
-.It Fn svc_getargs Ta Xr rpc_svc_reg 3 ,
-.It Fn svc_getcaller Ta Xr rpc_soc 3 ,
-.It Fn svc_getreq Ta Xr rpc_soc 3 ,
-.It Fn svc_getreqset Ta Xr rpc_svc_calls 3 ,
-.It Fn svc_getrpccaller Ta Xr rpc_svc_calls 3 ,
-.It Fn svc_kerb_reg Ta Xr kerberos_rpc 3 ,
-.It Fn svc_raw_create Ta Xr rpc_svc_create 3 ,
-.It Fn svc_reg Ta Xr rpc_svc_calls 3 ,
-.It Fn svc_register Ta Xr rpc_soc 3 ,
-.It Fn svc_run Ta Xr rpc_svc_reg 3 ,
-.It Fn svc_sendreply Ta Xr rpc_svc_reg 3 ,
-.It Fn svc_tli_create Ta Xr rpc_svc_create 3 ,
-.It Fn svc_tp_create Ta Xr rpc_svc_create 3 ,
-.It Fn svc_unreg Ta Xr rpc_svc_calls 3 ,
-.It Fn svc_unregister Ta  Xr rpc_soc 3 ,
-.It Fn svc_vc_create Ta Xr rpc_svc_create 3 ,
-.It Fn svcerr_auth Ta Xr rpc_svc_err 3 ,
-.It Fn svcerr_decode Ta Xr rpc_svc_err 3 ,
-.It Fn svcerr_noproc Ta Xr rpc_svc_err 3 ,
-.It Fn svcerr_noprog Ta Xr rpc_svc_err 3 ,
-.It Fn svcerr_progvers Ta Xr rpc_svc_err 3 ,
-.It Fn svcerr_systemerr Ta Xr rpc_svc_err 3 ,
-.It Fn svcerr_weakauth Ta Xr rpc_svc_err 3 ,
-.It Fn svcfd_create Ta Xr rpc_soc 3 ,
-.It Fn svcraw_create Ta Xr rpc_soc 3 ,
-.It Fn svctcp_create Ta Xr rpc_soc 3 ,
-.It Fn svcudp_bufcreate Ta Xr rpc_soc 3 ,
-.It Fn svcudp_create Ta Xr rpc_soc 3 ,
-.It Fn xdr_accepted_reply Ta Xr rpc_xdr 3 ,
-.It Fn xdr_authsys_parms Ta Xr rpc_xdr 3 ,
-.It Fn xdr_authunix_parms Ta Xr rpc_soc 3 ,
-.It Fn xdr_callhdr Ta Xr rpc_xdr 3 ,
-.It Fn xdr_callmsg Ta Xr rpc_xdr 3 ,
-.It Fn xdr_opaque_auth Ta Xr rpc_xdr 3 ,
-.It Fn xdr_rejected_reply Ta Xr rpc_xdr 3 ,
-.It Fn xdr_replymsg Ta Xr rpc_xdr 3 ,
-.It Fn xprt_register Ta Xr rpc_svc_calls 3 ,
-.It Fn xprt_unregister Ta Xr rpc_svc_calls 3 ,
+.It Fn auth_destroy Ta Xr rpc_clnt_auth 3
+.It Fn authdes_create Ta Xr rpc_soc 3
+.It Fn authnone_create Ta Xr rpc_clnt_auth 3
+.It Fn authsys_create Ta Xr rpc_clnt_auth 3
+.It Fn authsys_create_default Ta 

CVS commit: src/lib/libc/rpc

2012-03-18 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Mar 18 16:43:34 UTC 2012

Modified Files:
src/lib/libc/rpc: xdr.c

Log Message:
parenthesize.


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/lib/libc/rpc/xdr.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/rpc/xdr.c
diff -u src/lib/libc/rpc/xdr.c:1.29 src/lib/libc/rpc/xdr.c:1.30
--- src/lib/libc/rpc/xdr.c:1.29	Tue Mar 13 17:13:45 2012
+++ src/lib/libc/rpc/xdr.c	Sun Mar 18 12:43:34 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: xdr.c,v 1.29 2012/03/13 21:13:45 christos Exp $	*/
+/*	$NetBSD: xdr.c,v 1.30 2012/03/18 16:43:34 christos Exp $	*/
 
 /*
  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
@@ -35,7 +35,7 @@
 static char *sccsid = @(#)xdr.c 1.35 87/08/12;
 static char *sccsid = @(#)xdr.c	2.1 88/07/29 4.0 RPCSRC;
 #else
-__RCSID($NetBSD: xdr.c,v 1.29 2012/03/13 21:13:45 christos Exp $);
+__RCSID($NetBSD: xdr.c,v 1.30 2012/03/18 16:43:34 christos Exp $);
 #endif
 #endif
 
@@ -821,10 +821,10 @@ xdr_int64_t(XDR *xdrs, int64_t *llp)
 
 	switch (xdrs-x_op) {
 	case XDR_ENCODE:
-		ul[0] = (u_long)((uint64_t)*llp  32) 
-		(uint64_t)0xULL;
-		ul[1] = (u_long)((uint64_t)*llp) 
-		(uint64_t)0xULL;
+		ul[0] = (u_long)(((uint64_t)*llp  32) 
+		(uint64_t)0xULL);
+		ul[1] = (u_long)(((uint64_t)*llp) 
+		(uint64_t)0xULL);
 		if (XDR_PUTLONG(xdrs, (long *)ul[0]) == FALSE)
 			return (FALSE);
 		return (XDR_PUTLONG(xdrs, (long *)ul[1]));



CVS commit: src/lib/libc/rpc

2012-01-02 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Mon Jan  2 21:29:55 UTC 2012

Modified Files:
src/lib/libc/rpc: xdr_sizeof.c

Log Message:
Remove unnecessary cast to caddr_t.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/lib/libc/rpc/xdr_sizeof.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/rpc/xdr_sizeof.c
diff -u src/lib/libc/rpc/xdr_sizeof.c:1.2 src/lib/libc/rpc/xdr_sizeof.c:1.3
--- src/lib/libc/rpc/xdr_sizeof.c:1.2	Mon Jul  4 11:01:40 2011
+++ src/lib/libc/rpc/xdr_sizeof.c	Mon Jan  2 21:29:55 2012
@@ -39,7 +39,7 @@
 #if 0
 __FBSDID($FreeBSD: src/lib/libc/xdr/xdr_sizeof.c,v 1.5.38.1 2010/12/21 17:10:29 kensmith Exp $);
 #else
-__RCSID($NetBSD: xdr_sizeof.c,v 1.2 2011/07/04 11:01:40 mrg Exp $);
+__RCSID($NetBSD: xdr_sizeof.c,v 1.3 2012/01/02 21:29:55 dholland Exp $);
 #endif
 
 #include namespace.h
@@ -117,7 +117,7 @@ x_inline(xdrs, len)
 		/* Free the earlier space and allocate new area */
 		if (xdrs-x_private)
 			free(xdrs-x_private);
-		if ((xdrs-x_private = (caddr_t) malloc(len)) == NULL) {
+		if ((xdrs-x_private = malloc(len)) == NULL) {
 			xdrs-x_base = 0;
 			return (NULL);
 		}



CVS commit: src/lib/libc/rpc

2011-07-08 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Fri Jul  8 19:28:22 UTC 2011

Modified Files:
src/lib/libc/rpc: xdr.3

Log Message:
Bump date for xdr_sizeof. Remove trailing whitespace.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/lib/libc/rpc/xdr.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/rpc/xdr.3
diff -u src/lib/libc/rpc/xdr.3:1.13 src/lib/libc/rpc/xdr.3:1.14
--- src/lib/libc/rpc/xdr.3:1.13	Mon Jul  4 08:19:51 2011
+++ src/lib/libc/rpc/xdr.3	Fri Jul  8 19:28:22 2011
@@ -1,7 +1,7 @@
 .\	@(#)xdr.3n	2.2 88/08/03 4.0 RPCSRC; from 1.16 88/03/14 SMI
-.\	$NetBSD: xdr.3,v 1.13 2011/07/04 08:19:51 manu Exp $
+.\	$NetBSD: xdr.3,v 1.14 2011/07/08 19:28:22 wiz Exp $
 .\
-.Dd April 17, 2003
+.Dd July 4, 2011
 .Dt XDR 3
 .Os
 .Sh NAME
@@ -382,7 +382,7 @@
 and their external representations.
 This routine returns one if it succeeds, zero otherwise.
 .It Fn xdr_sizeof
-This routine returns the amount of memory required to encode 
+This routine returns the amount of memory required to encode
 .Fa data
 using filter
 .Fa func .



CVS commit: src/lib/libc/rpc

2011-07-04 Thread Emmanuel Dreyfus
Module Name:src
Committed By:   manu
Date:   Mon Jul  4 08:19:51 UTC 2011

Modified Files:
src/lib/libc/rpc: xdr.3

Log Message:
Document newly imported xdr_sizeof()


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/lib/libc/rpc/xdr.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/rpc/xdr.3
diff -u src/lib/libc/rpc/xdr.3:1.12 src/lib/libc/rpc/xdr.3:1.13
--- src/lib/libc/rpc/xdr.3:1.12	Tue Oct 13 21:39:55 2009
+++ src/lib/libc/rpc/xdr.3	Mon Jul  4 08:19:51 2011
@@ -1,5 +1,5 @@
 .\	@(#)xdr.3n	2.2 88/08/03 4.0 RPCSRC; from 1.16 88/03/14 SMI
-.\	$NetBSD: xdr.3,v 1.12 2009/10/13 21:39:55 joerg Exp $
+.\	$NetBSD: xdr.3,v 1.13 2011/07/04 08:19:51 manu Exp $
 .\
 .Dd April 17, 2003
 .Dt XDR 3
@@ -31,6 +31,7 @@
 .Nm xdr_reference ,
 .Nm xdr_setpos ,
 .Nm xdr_short ,
+.Nm xdr_sizeof ,
 .Nm xdrstdio_create ,
 .Nm xdr_string ,
 .Nm xdr_u_char ,
@@ -99,6 +100,8 @@
 .Fn xdr_setpos XDR *xdrs u_int pos
 .Ft int
 .Fn xdr_short XDR *xdrs short *sp
+.Ft nsigned long
+.Fn xdr_sizeof xdrproc_t func void *data
 .Ft void
 .Fn xdrstdio_create XDR *xdrs FILE *file enum xdr_op op
 .Ft int
@@ -378,6 +381,11 @@
 A filter primitive that translates between C short integers
 and their external representations.
 This routine returns one if it succeeds, zero otherwise.
+.It Fn xdr_sizeof
+This routine returns the amount of memory required to encode 
+.Fa data
+using filter
+.Fa func .
 .It Fn xdrstdio_create
 This routine initializes the XDR stream object pointed to by
 .Fa xdrs .



CVS commit: src/lib/libc/rpc

2011-07-04 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Mon Jul  4 11:01:41 UTC 2011

Modified Files:
src/lib/libc/rpc: xdr_sizeof.c

Log Message:
insert some (uintptr_t) between int and pointer casts.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/lib/libc/rpc/xdr_sizeof.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/rpc/xdr_sizeof.c
diff -u src/lib/libc/rpc/xdr_sizeof.c:1.1 src/lib/libc/rpc/xdr_sizeof.c:1.2
--- src/lib/libc/rpc/xdr_sizeof.c:1.1	Mon Jul  4 07:54:38 2011
+++ src/lib/libc/rpc/xdr_sizeof.c	Mon Jul  4 11:01:40 2011
@@ -39,7 +39,7 @@
 #if 0
 __FBSDID($FreeBSD: src/lib/libc/xdr/xdr_sizeof.c,v 1.5.38.1 2010/12/21 17:10:29 kensmith Exp $);
 #else
-__RCSID($NetBSD: xdr_sizeof.c,v 1.1 2011/07/04 07:54:38 manu Exp $);
+__RCSID($NetBSD: xdr_sizeof.c,v 1.2 2011/07/04 11:01:40 mrg Exp $);
 #endif
 
 #include namespace.h
@@ -109,7 +109,7 @@
 	if (xdrs-x_op != XDR_ENCODE) {
 		return (NULL);
 	}
-	if (len  (u_int)xdrs-x_base) {
+	if (len  (u_int)(uintptr_t)xdrs-x_base) {
 		/* x_private was already allocated */
 		xdrs-x_handy += len;
 		return ((int32_t *) xdrs-x_private);
@@ -121,7 +121,7 @@
 			xdrs-x_base = 0;
 			return (NULL);
 		}
-		xdrs-x_base = (caddr_t) len;
+		xdrs-x_base = (caddr_t)(uintptr_t)len;
 		xdrs-x_handy += len;
 		return ((int32_t *) xdrs-x_private);
 	}



CVS commit: src/lib/libc/rpc

2011-02-04 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Feb  4 17:36:55 UTC 2011

Modified Files:
src/lib/libc/rpc: svc_vc.c

Log Message:
knf - no functional changes


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/lib/libc/rpc/svc_vc.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/rpc/svc_vc.c
diff -u src/lib/libc/rpc/svc_vc.c:1.22 src/lib/libc/rpc/svc_vc.c:1.23
--- src/lib/libc/rpc/svc_vc.c:1.22	Wed Feb 11 23:38:52 2009
+++ src/lib/libc/rpc/svc_vc.c	Fri Feb  4 12:36:54 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: svc_vc.c,v 1.22 2009/02/12 04:38:52 lukem Exp $	*/
+/*	$NetBSD: svc_vc.c,v 1.23 2011/02/04 17:36:54 christos Exp $	*/
 
 /*
  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
@@ -35,7 +35,7 @@
 static char *sccsid = @(#)svc_tcp.c 1.21 87/08/11 Copyr 1984 Sun Micro;
 static char *sccsid = @(#)svc_tcp.c	2.2 88/08/01 4.0 RPCSRC;
 #else
-__RCSID($NetBSD: svc_vc.c,v 1.22 2009/02/12 04:38:52 lukem Exp $);
+__RCSID($NetBSD: svc_vc.c,v 1.23 2011/02/04 17:36:54 christos Exp $);
 #endif
 #endif
 
@@ -79,23 +79,22 @@
 extern rwlock_t svc_fd_lock;
 #endif
 
-static SVCXPRT *makefd_xprt __P((int, u_int, u_int));
-static bool_t rendezvous_request __P((SVCXPRT *, struct rpc_msg *));
-static enum xprt_stat rendezvous_stat __P((SVCXPRT *));
-static void svc_vc_destroy __P((SVCXPRT *));
-static void __svc_vc_dodestroy __P((SVCXPRT *));
-static int read_vc __P((caddr_t, caddr_t, int));
-static int write_vc __P((caddr_t, caddr_t, int));
-static enum xprt_stat svc_vc_stat __P((SVCXPRT *));
-static bool_t svc_vc_recv __P((SVCXPRT *, struct rpc_msg *));
-static bool_t svc_vc_getargs __P((SVCXPRT *, xdrproc_t, caddr_t));
-static bool_t svc_vc_freeargs __P((SVCXPRT *, xdrproc_t, caddr_t));
-static bool_t svc_vc_reply __P((SVCXPRT *, struct rpc_msg *));
-static void svc_vc_rendezvous_ops __P((SVCXPRT *));
-static void svc_vc_ops __P((SVCXPRT *));
-static bool_t svc_vc_control __P((SVCXPRT *, const u_int, void *));
-static bool_t svc_vc_rendezvous_control __P((SVCXPRT *, const u_int,
-	 void *));
+static SVCXPRT *makefd_xprt(int, u_int, u_int);
+static bool_t rendezvous_request(SVCXPRT *, struct rpc_msg *);
+static enum xprt_stat rendezvous_stat(SVCXPRT *);
+static void svc_vc_destroy(SVCXPRT *);
+static void __svc_vc_dodestroy(SVCXPRT *);
+static int read_vc(caddr_t, caddr_t, int);
+static int write_vc(caddr_t, caddr_t, int);
+static enum xprt_stat svc_vc_stat(SVCXPRT *);
+static bool_t svc_vc_recv(SVCXPRT *, struct rpc_msg *);
+static bool_t svc_vc_getargs(SVCXPRT *, xdrproc_t, caddr_t);
+static bool_t svc_vc_freeargs(SVCXPRT *, xdrproc_t, caddr_t);
+static bool_t svc_vc_reply(SVCXPRT *, struct rpc_msg *);
+static void svc_vc_rendezvous_ops(SVCXPRT *);
+static void svc_vc_ops(SVCXPRT *);
+static bool_t svc_vc_control(SVCXPRT *, const u_int, void *);
+static bool_t svc_vc_rendezvous_control(SVCXPRT *, const u_int, void *);
 
 struct cf_rendezvous { /* kept in xprt-xp_p1 for rendezvouser */
 	u_int sendsize;
@@ -132,10 +131,7 @@
  * 0 = use the system default.
  */
 SVCXPRT *
-svc_vc_create(fd, sendsize, recvsize)
-	int fd;
-	u_int sendsize;
-	u_int recvsize;
+svc_vc_create(int fd, u_int sendsize, u_int recvsize)
 {
 	SVCXPRT *xprt;
 	struct cf_rendezvous *r = NULL;
@@ -192,13 +188,13 @@
 
 	xprt-xp_rtaddr.maxlen = sizeof (struct sockaddr_storage);
 	xprt_register(xprt);
-	return (xprt);
+	return xprt;
 cleanup_svc_vc_create:
 	if (xprt)
 		mem_free(xprt, sizeof(*xprt));
 	if (r != NULL)
 		mem_free(r, sizeof(*r));
-	return (NULL);
+	return NULL;
 }
 
 /*
@@ -206,10 +202,7 @@
  * descriptor as its first input.
  */
 SVCXPRT *
-svc_fd_create(fd, sendsize, recvsize)
-	int fd;
-	u_int sendsize;
-	u_int recvsize;
+svc_fd_create(int fd, u_int sendsize, u_int recvsize)
 {
 	struct sockaddr_storage ss;
 	socklen_t slen;
@@ -263,10 +256,7 @@
 }
 
 static SVCXPRT *
-makefd_xprt(fd, sendsize, recvsize)
-	int fd;
-	u_int sendsize;
-	u_int recvsize;
+makefd_xprt(int fd, u_int sendsize, u_int recvsize)
 {
 	SVCXPRT *xprt;
 	struct cf_conn *cd;
@@ -295,7 +285,7 @@
 			goto out;
 
 	xprt_register(xprt);
-	return (xprt);
+	return xprt;
 out:
 	warn(svc_tcp: makefd_xprt);
 	if (xprt)
@@ -305,9 +295,7 @@
 
 /*ARGSUSED*/
 static bool_t
-rendezvous_request(xprt, msg)
-	SVCXPRT *xprt;
-	struct rpc_msg *msg;
+rendezvous_request(SVCXPRT *xprt, struct rpc_msg *msg)
 {
 	int sock, flags;
 	struct cf_rendezvous *r;
@@ -337,7 +325,7 @@
 			if (__svc_clean_idle(cleanfds, 0, FALSE))
 goto again;
 		}
-		return (FALSE);
+		return FALSE;
 	}
 	/*
 	 * make a new transporter (re-uses xprt)
@@ -380,24 +368,22 @@
 
 	(void)gettimeofday(cd-last_recv_time, NULL);
 
-	return (FALSE); /* there is never an rpc msg to be processed */
+	return FALSE; /* there is never an rpc msg to be processed */
 out:
 	(void)close(sock);
-	return (FALSE); /* there was an error */
+	return FALSE; /* there was an 

CVS commit: src/lib/libc/rpc

2011-02-04 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Feb  4 17:38:15 UTC 2011

Modified Files:
src/lib/libc/rpc: svc_vc.c

Log Message:
PR/44514: Andrey Simonenko: Buffer underflow in RPC library for non-blocking
TCP sockets


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/lib/libc/rpc/svc_vc.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/rpc/svc_vc.c
diff -u src/lib/libc/rpc/svc_vc.c:1.23 src/lib/libc/rpc/svc_vc.c:1.24
--- src/lib/libc/rpc/svc_vc.c:1.23	Fri Feb  4 12:36:54 2011
+++ src/lib/libc/rpc/svc_vc.c	Fri Feb  4 12:38:15 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: svc_vc.c,v 1.23 2011/02/04 17:36:54 christos Exp $	*/
+/*	$NetBSD: svc_vc.c,v 1.24 2011/02/04 17:38:15 christos Exp $	*/
 
 /*
  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
@@ -35,7 +35,7 @@
 static char *sccsid = @(#)svc_tcp.c 1.21 87/08/11 Copyr 1984 Sun Micro;
 static char *sccsid = @(#)svc_tcp.c	2.2 88/08/01 4.0 RPCSRC;
 #else
-__RCSID($NetBSD: svc_vc.c,v 1.23 2011/02/04 17:36:54 christos Exp $);
+__RCSID($NetBSD: svc_vc.c,v 1.24 2011/02/04 17:38:15 christos Exp $);
 #endif
 #endif
 
@@ -583,7 +583,7 @@
 cd-strm_stat = XPRT_DIED;
 return -1;
 			}
-			if (cd-nonblock  i != cnt) {
+			if (cd-nonblock) {
 /*
  * For non-blocking connections, do not
  * take more than 2 seconds writing the
@@ -597,6 +597,7 @@
 	return -1;
 }
 			}
+			i = 0;
 		}
 	}
 	return len;



CVS commit: src/lib/libc/rpc

2010-12-07 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Wed Dec  8 02:06:38 UTC 2010

Modified Files:
src/lib/libc/rpc: clnt_dg.c clnt_simple.c clnt_vc.c getnetconfig.c
mt_misc.c rpc_generic.c rpc_soc.c

Log Message:
Use __isthreaded from reentrant.h and don't redeclare it.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/lib/libc/rpc/clnt_dg.c \
src/lib/libc/rpc/rpc_generic.c
cvs rdiff -u -r1.29 -r1.30 src/lib/libc/rpc/clnt_simple.c
cvs rdiff -u -r1.16 -r1.17 src/lib/libc/rpc/clnt_vc.c
cvs rdiff -u -r1.17 -r1.18 src/lib/libc/rpc/getnetconfig.c
cvs rdiff -u -r1.7 -r1.8 src/lib/libc/rpc/mt_misc.c
cvs rdiff -u -r1.12 -r1.13 src/lib/libc/rpc/rpc_soc.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/rpc/clnt_dg.c
diff -u src/lib/libc/rpc/clnt_dg.c:1.23 src/lib/libc/rpc/clnt_dg.c:1.24
--- src/lib/libc/rpc/clnt_dg.c:1.23	Thu Feb 12 04:33:20 2009
+++ src/lib/libc/rpc/clnt_dg.c	Wed Dec  8 02:06:38 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: clnt_dg.c,v 1.23 2009/02/12 04:33:20 lukem Exp $	*/
+/*	$NetBSD: clnt_dg.c,v 1.24 2010/12/08 02:06:38 joerg Exp $	*/
 
 /*
  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
@@ -39,7 +39,7 @@
 #if 0
 static char sccsid[] = @(#)clnt_dg.c 1.19 89/03/16 Copyr 1988 Sun Micro;
 #else
-__RCSID($NetBSD: clnt_dg.c,v 1.23 2009/02/12 04:33:20 lukem Exp $);
+__RCSID($NetBSD: clnt_dg.c,v 1.24 2010/12/08 02:06:38 joerg Exp $);
 #endif
 #endif
 
@@ -99,7 +99,6 @@
  */
 static int	*dg_fd_locks;
 #ifdef _REENTRANT
-extern int __isthreaded;
 #define __rpc_lock_value __isthreaded;
 extern mutex_t clnt_fd_lock;
 static cond_t	*dg_cv;
Index: src/lib/libc/rpc/rpc_generic.c
diff -u src/lib/libc/rpc/rpc_generic.c:1.23 src/lib/libc/rpc/rpc_generic.c:1.24
--- src/lib/libc/rpc/rpc_generic.c:1.23	Fri Apr 25 17:44:44 2008
+++ src/lib/libc/rpc/rpc_generic.c	Wed Dec  8 02:06:38 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: rpc_generic.c,v 1.23 2008/04/25 17:44:44 christos Exp $	*/
+/*	$NetBSD: rpc_generic.c,v 1.24 2010/12/08 02:06:38 joerg Exp $	*/
 
 /*
  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
@@ -41,7 +41,7 @@
 
 #include sys/cdefs.h
 #if defined(LIBC_SCCS)  !defined(lint)
-__RCSID($NetBSD: rpc_generic.c,v 1.23 2008/04/25 17:44:44 christos Exp $);
+__RCSID($NetBSD: rpc_generic.c,v 1.24 2010/12/08 02:06:38 joerg Exp $);
 #endif
 
 #include namespace.h
@@ -258,8 +258,6 @@
 	static char *netid_udp_main;
 	struct netconfig *dummy;
 #ifdef _REENTRANT
-	extern int __isthreaded;
-
 	if (__isthreaded == 0) {
 		netid_udp = netid_udp_main;
 		netid_tcp = netid_tcp_main;

Index: src/lib/libc/rpc/clnt_simple.c
diff -u src/lib/libc/rpc/clnt_simple.c:1.29 src/lib/libc/rpc/clnt_simple.c:1.30
--- src/lib/libc/rpc/clnt_simple.c:1.29	Fri Nov  3 23:16:12 2006
+++ src/lib/libc/rpc/clnt_simple.c	Wed Dec  8 02:06:38 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: clnt_simple.c,v 1.29 2006/11/03 23:16:12 christos Exp $	*/
+/*	$NetBSD: clnt_simple.c,v 1.30 2010/12/08 02:06:38 joerg Exp $	*/
 
 /*
  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
@@ -39,7 +39,7 @@
 #if 0
 static char sccsid[] = @(#)clnt_simple.c 1.49 89/01/31 Copyr 1984 Sun Micro;
 #else
-__RCSID($NetBSD: clnt_simple.c,v 1.29 2006/11/03 23:16:12 christos Exp $);
+__RCSID($NetBSD: clnt_simple.c,v 1.30 2010/12/08 02:06:38 joerg Exp $);
 #endif
 #endif
 
@@ -131,7 +131,6 @@
 	struct rpc_call_private *rcp = (struct rpc_call_private *) 0;
 	enum clnt_stat clnt_stat;
 	struct timeval timeout, tottimeout;
-	extern int __isthreaded;
 
 	_DIAGASSERT(host != NULL);
 	/* XXX: in may be NULL ??? */

Index: src/lib/libc/rpc/clnt_vc.c
diff -u src/lib/libc/rpc/clnt_vc.c:1.16 src/lib/libc/rpc/clnt_vc.c:1.17
--- src/lib/libc/rpc/clnt_vc.c:1.16	Thu Feb 12 16:24:59 2009
+++ src/lib/libc/rpc/clnt_vc.c	Wed Dec  8 02:06:38 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: clnt_vc.c,v 1.16 2009/02/12 16:24:59 uebayasi Exp $	*/
+/*	$NetBSD: clnt_vc.c,v 1.17 2010/12/08 02:06:38 joerg Exp $	*/
 
 /*
  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
@@ -36,7 +36,7 @@
 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.16 2009/02/12 16:24:59 uebayasi Exp $);
+__RCSID($NetBSD: clnt_vc.c,v 1.17 2010/12/08 02:06:38 joerg Exp $);
 #endif
 #endif
  
@@ -126,7 +126,6 @@
  */
 #ifdef _REENTRANT
 static int  *vc_fd_locks;
-extern int __isthreaded;
 #define __rpc_lock_value __isthreaded;
 extern mutex_t  clnt_fd_lock;
 static cond_t   *vc_cv;

Index: src/lib/libc/rpc/getnetconfig.c
diff -u src/lib/libc/rpc/getnetconfig.c:1.17 src/lib/libc/rpc/getnetconfig.c:1.18
--- src/lib/libc/rpc/getnetconfig.c:1.17	Fri Apr 25 17:44:44 2008
+++ src/lib/libc/rpc/getnetconfig.c	Wed Dec  8 02:06:38 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: getnetconfig.c,v 1.17 2008/04/25 17:44:44 christos Exp $	*/
+/*	$NetBSD: 

CVS commit: src/lib/libc/rpc

2010-11-23 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Nov 23 14:02:01 UTC 2010

Modified Files:
src/lib/libc/rpc: xdr_rec.c

Log Message:
PR/44132: Wolfgang Stukenbrock: libc/rpc may overwrite not-allocated memory
Return XPRT_DIED when realloc fails for lack of a better error.


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/lib/libc/rpc/xdr_rec.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/rpc/xdr_rec.c
diff -u src/lib/libc/rpc/xdr_rec.c:1.30 src/lib/libc/rpc/xdr_rec.c:1.31
--- src/lib/libc/rpc/xdr_rec.c:1.30	Wed Feb 11 23:40:40 2009
+++ src/lib/libc/rpc/xdr_rec.c	Tue Nov 23 09:02:01 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: xdr_rec.c,v 1.30 2009/02/12 04:40:40 lukem Exp $	*/
+/*	$NetBSD: xdr_rec.c,v 1.31 2010/11/23 14:02:01 christos Exp $	*/
 
 /*
  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
@@ -35,7 +35,7 @@
 static char *sccsid = @(#)xdr_rec.c 1.21 87/08/11 Copyr 1984 Sun Micro;
 static char *sccsid = @(#)xdr_rec.c	2.2 88/08/01 4.0 RPCSRC;
 #else
-__RCSID($NetBSD: xdr_rec.c,v 1.30 2009/02/12 04:40:40 lukem Exp $);
+__RCSID($NetBSD: xdr_rec.c,v 1.31 2010/11/23 14:02:01 christos Exp $);
 #endif
 #endif
 
@@ -581,8 +581,12 @@
 			return FALSE;
 		}
 		rstrm-in_reclen += fraglen;
-		if ((u_int)rstrm-in_reclen  rstrm-recvsize)
-			realloc_stream(rstrm, rstrm-in_reclen);
+		if ((u_int)rstrm-in_reclen  rstrm-recvsize) {
+			if (!realloc_stream(rstrm, rstrm-in_reclen)) {
+*statp = XPRT_DIED;
+return FALSE;
+			}
+		}
 		if (rstrm-in_header  LAST_FRAG) {
 			rstrm-in_header = ~LAST_FRAG;
 			rstrm-last_frag = TRUE;



CVS commit: src/lib/libc/rpc

2010-07-08 Thread Matthias Scheler
Module Name:src
Committed By:   tron
Date:   Thu Jul  8 20:12:37 UTC 2010

Modified Files:
src/lib/libc/rpc: svc.c

Log Message:
Explicitly cast argument of ffs(3) to fix lint error.


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/lib/libc/rpc/svc.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/rpc/svc.c
diff -u src/lib/libc/rpc/svc.c:1.29 src/lib/libc/rpc/svc.c:1.30
--- src/lib/libc/rpc/svc.c:1.29	Thu Jul  8 14:45:08 2010
+++ src/lib/libc/rpc/svc.c	Thu Jul  8 20:12:37 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: svc.c,v 1.29 2010/07/08 14:45:08 rmind Exp $	*/
+/*	$NetBSD: svc.c,v 1.30 2010/07/08 20:12:37 tron 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.29 2010/07/08 14:45:08 rmind Exp $);
+__RCSID($NetBSD: svc.c,v 1.30 2010/07/08 20:12:37 tron Exp $);
 #endif
 #endif
 
@@ -643,7 +643,7 @@
 
 	maskp = readfds-fds_bits;
 	for (sock = 0; sock  FD_SETSIZE; sock += NFDBITS) {
-	for (mask = *maskp++; (bit = ffs(mask)) != 0;
+	for (mask = *maskp++; (bit = ffs((int)mask)) != 0;
 		mask ^= (1  (bit - 1))) {
 		/* sock has input waiting */
 		fd = sock + bit - 1;



CVS commit: src/lib/libc/rpc

2009-10-13 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Tue Oct 13 21:39:56 UTC 2009

Modified Files:
src/lib/libc/rpc: xdr.3

Log Message:
No .Pp inside .Rs/.Re.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/lib/libc/rpc/xdr.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/rpc/xdr.3
diff -u src/lib/libc/rpc/xdr.3:1.11 src/lib/libc/rpc/xdr.3:1.12
--- src/lib/libc/rpc/xdr.3:1.11	Sat Apr 11 20:14:35 2009
+++ src/lib/libc/rpc/xdr.3	Tue Oct 13 21:39:55 2009
@@ -1,5 +1,5 @@
 .\	@(#)xdr.3n	2.2 88/08/03 4.0 RPCSRC; from 1.16 88/03/14 SMI
-.\	$NetBSD: xdr.3,v 1.11 2009/04/11 20:14:35 joerg Exp $
+.\	$NetBSD: xdr.3,v 1.12 2009/10/13 21:39:55 joerg Exp $
 .\
 .Dd April 17, 2003
 .Dt XDR 3
@@ -505,7 +505,6 @@
 .Re
 .Rs
 .%B eXternal Data Representation: Sun Technical Notes
-.Pp
 .Re
 .Rs
 .%A Sun Microsystems, Inc., USC-ISI



CVS commit: src/lib/libc/rpc

2009-04-11 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Sat Apr 11 20:14:35 UTC 2009

Modified Files:
src/lib/libc/rpc: xdr.3

Log Message:
Add missing .Re.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/lib/libc/rpc/xdr.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/rpc/xdr.3
diff -u src/lib/libc/rpc/xdr.3:1.10 src/lib/libc/rpc/xdr.3:1.11
--- src/lib/libc/rpc/xdr.3:1.10	Sun Sep  7 16:22:21 2003
+++ src/lib/libc/rpc/xdr.3	Sat Apr 11 20:14:35 2009
@@ -1,5 +1,5 @@
 .\	@(#)xdr.3n	2.2 88/08/03 4.0 RPCSRC; from 1.16 88/03/14 SMI
-.\	$NetBSD: xdr.3,v 1.10 2003/09/07 16:22:21 wiz Exp $
+.\	$NetBSD: xdr.3,v 1.11 2009/04/11 20:14:35 joerg Exp $
 .\
 .Dd April 17, 2003
 .Dt XDR 3
@@ -506,6 +506,7 @@
 .Rs
 .%B eXternal Data Representation: Sun Technical Notes
 .Pp
+.Re
 .Rs
 .%A Sun Microsystems, Inc., USC-ISI
 .%T XDR: External Data Representation Standard



CVS commit: src/lib/libc/rpc

2009-04-08 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Thu Apr  9 00:06:44 UTC 2009

Modified Files:
src/lib/libc/rpc: rpc_clnt_create.3

Log Message:
Fix markup


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/lib/libc/rpc/rpc_clnt_create.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/rpc/rpc_clnt_create.3
diff -u src/lib/libc/rpc/rpc_clnt_create.3:1.9 src/lib/libc/rpc/rpc_clnt_create.3:1.10
--- src/lib/libc/rpc/rpc_clnt_create.3:1.9	Wed Apr 16 13:34:43 2003
+++ src/lib/libc/rpc/rpc_clnt_create.3	Thu Apr  9 00:06:44 2009
@@ -2,7 +2,7 @@
 .\ Copyright 1989 ATT
 .\ @(#)rpc_clnt_create 1.5 89/07/24 SMI;
 .\ Copyright (c) 1988 Sun Microsystems, Inc. - All Rights Reserved.
-.\	$NetBSD: rpc_clnt_create.3,v 1.9 2003/04/16 13:34:43 wiz Exp $
+.\	$NetBSD: rpc_clnt_create.3,v 1.10 2009/04/09 00:06:44 joerg Exp $
 .Dd May 7, 1993
 .Dt RPC_CLNT_CREATE 3
 .Os
@@ -287,7 +287,6 @@
 on each call.
 .Pp
 .It Fn clnt_raw_create
-.IP
 This routine creates an RPC
 client handle for the remote program
 .Fa prognum
@@ -328,7 +327,7 @@
 For connectionless transports, if
 .Fa svcaddr
 is
-..Dv NULL ,
+.Dv NULL ,
 .Dv RPC_UNKNOWNADDR
 error is set.
 .Fa fildes