CVS commit: src/lib/libc/rpc

2024-04-11 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Apr 11 18:41:03 UTC 2024

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

Log Message:
avoid lint warning on the vax


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 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.41 src/lib/libc/rpc/xdr_float.c:1.42
--- src/lib/libc/rpc/xdr_float.c:1.41	Mon Feb 15 06:07:48 2016
+++ src/lib/libc/rpc/xdr_float.c	Thu Apr 11 14:41:03 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: xdr_float.c,v 1.41 2016/02/15 11:07:48 martin Exp $	*/
+/*	$NetBSD: xdr_float.c,v 1.42 2024/04/11 18:41:03 christos 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.41 2016/02/15 11:07:48 martin Exp $");
+__RCSID("$NetBSD: xdr_float.c,v 1.42 2024/04/11 18:41:03 christos Exp $");
 #endif
 #endif
 
@@ -254,6 +254,7 @@ xdr_double(XDR *xdrs, double *dp)
 goto shipit;
 			}
 		}
+		/*LINTED: possible overflow*/
 		id.exp = vd.exp - VAX_DBL_BIAS + IEEE_DBL_BIAS;
 		id.mantissa1 = (vd.mantissa1 << 13) |
 			((unsigned int)vd.mantissa2 >> 3);
@@ -296,6 +297,7 @@ xdr_double(XDR *xdrs, double *dp)
 goto doneit;
 			}
 		}
+		/*LINTED: can overflow */
 		vd.exp = id.exp - IEEE_DBL_BIAS + VAX_DBL_BIAS;
 		vd.mantissa1 = ((unsigned int)id.mantissa1 >> 13);
 		vd.mantissa2 = ((id.mantissa1 & MASK(13)) << 3) |



CVS commit: src/lib/libc/rpc

2024-04-11 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Apr 11 18:41:03 UTC 2024

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

Log Message:
avoid lint warning on the vax


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 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.



CVS commit: src/lib/libc/rpc

2024-03-22 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Fri Mar 22 19:45:22 UTC 2024

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

Log Message:
Fix few typos in comments.


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 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.40 src/lib/libc/rpc/xdr_rec.c:1.41
--- src/lib/libc/rpc/xdr_rec.c:1.40	Tue Jan 23 17:24:38 2024
+++ src/lib/libc/rpc/xdr_rec.c	Fri Mar 22 19:45:22 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: xdr_rec.c,v 1.40 2024/01/23 17:24:38 christos Exp $	*/
+/*	$NetBSD: xdr_rec.c,v 1.41 2024/03/22 19:45:22 andvar 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.40 2024/01/23 17:24:38 christos Exp $");
+__RCSID("$NetBSD: xdr_rec.c,v 1.41 2024/03/22 19:45:22 andvar Exp $");
 #endif
 #endif
 
@@ -242,7 +242,7 @@ xdrrec_create(
 
 
 /*
- * The reoutines defined below are the xdr ops which will go into the
+ * The routines defined below are the xdr ops which will go into the
  * xdr handle filled in by xdrrec_create.
  */
 
@@ -503,9 +503,9 @@ xdrrec_eof(XDR *xdrs)
 
 /*
  * The client must tell the package when an end-of-record has occurred.
- * The second paraemters tells whether the record should be flushed to the
+ * The second parameters tells whether the record should be flushed to the
  * (output) tcp stream.  (This let's the package support batched or
- * pipelined procedure calls.)  TRUE => immmediate flush to tcp connection.
+ * pipelined procedure calls.)  TRUE => immediate flush to tcp connection.
  */
 bool_t
 xdrrec_endofrecord(XDR *xdrs, int sendnow)



CVS commit: src/lib/libc/rpc

2024-03-22 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Fri Mar 22 19:45:22 UTC 2024

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

Log Message:
Fix few typos in comments.


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 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.



CVS commit: src/lib/libc/rpc

2022-12-04 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Sun Dec  4 23:02:57 UTC 2022

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

Log Message:
getnetpath(3): Sprinkle some markup


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/lib/libc/rpc/getnetpath.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/getnetpath.3
diff -u src/lib/libc/rpc/getnetpath.3:1.6 src/lib/libc/rpc/getnetpath.3:1.7
--- src/lib/libc/rpc/getnetpath.3:1.6	Wed Apr 16 13:34:43 2003
+++ src/lib/libc/rpc/getnetpath.3	Sun Dec  4 23:02:57 2022
@@ -1,5 +1,5 @@
 .\"	@(#)getnetpath.3n 1.26 93/05/07 SMI; from SVr4
-.\"	$NetBSD: getnetpath.3,v 1.6 2003/04/16 13:34:43 wiz Exp $
+.\"	$NetBSD: getnetpath.3,v 1.7 2022/12/04 23:02:57 uwe Exp $
 .\" Copyright 1989 AT
 .Dd April 22, 2000
 .Dt GETNETPATH 3
@@ -25,37 +25,51 @@ network configuration database,
 .Pa /etc/netconfig ,
 as it is
 .Dq filtered
-by the NETPATH
-environment variable (see
-.Xr environ 7 ) .
+by the
+.Ev NETPATH
+environment variable
+.Po see
+.Xr environ 7
+.Pc .
 See
 .Xr getnetconfig 3
 for other routines that also access the
 network configuration database directly.
-The NETPATH variable is a list of colon-separated network identifiers.
+The
+.Ev NETPATH
+variable is a list of colon-separated network identifiers.
 .Pp
 .Fn getnetpath
 returns a pointer to the
 netconfig database entry corresponding to the first valid
-NETPATH component.
-The netconfig entry is formatted as a struct netconfig.
+.Ev NETPATH
+component.
+The netconfig entry is formatted as a
+.Vt struct netconfig .
 On each subsequent call,
 .Fn getnetpath
 returns a pointer to the netconfig entry that corresponds to the next
-valid NETPATH component.
+valid
+.Ev NETPATH
+component.
 .Fn getnetpath
 can thus be used to search the netconfig database for all networks
-included in the NETPATH variable.
-When NETPATH has been exhausted,
+included in the
+.Ev NETPATH
+variable.
+When
+.Ev NETPATH
+has been exhausted,
 .Fn getnetpath
-returns NULL.
+returns
+.Dv NULL .
 .Pp
 A call to
 .Fn setnetpath
 .Dq binds
 to or
 .Dq rewinds
-NETPATH.
+.Ev NETPATH .
 .Fn setnetpath
 must be called before the first call to
 .Fn getnetpath
@@ -64,14 +78,20 @@ It returns a handle that is used by
 .Fn getnetpath .
 .Pp
 .Fn getnetpath
-silently ignores invalid NETPATH
+silently ignores invalid
+.Ev NETPATH
 components.
-A NETPATH component is invalid if there is no corresponding
+A
+.Ev NETPATH
+component is invalid if there is no corresponding
 entry in the netconfig database.
 .Pp
-If the NETPATH variable is unset,
+If the
+.Ev NETPATH
+variable is unset,
 .Fn getnetpath
-behaves as if NETPATH
+behaves as if
+.Ev NETPATH
 were set to the sequence of
 .Dq default
 or
@@ -84,26 +104,32 @@ order in which they are listed.
 .Fn endnetpath
 may be called to
 .Dq unbind
-from NETPATH
+from
+.Ev NETPATH
 when processing is complete, releasing resources for reuse.
 Programmers should be aware, however, that
 .Fn endnetpath
 frees all memory allocated by
 .Fn getnetpath
-for the struct netconfig data structure.
+for the
+.Vt struct netconfig
+data structure.
 .Sh RETURN VALUES
 .Fn setnetpath
 returns a handle that is used by
 .Fn getnetpath .
 In case of an error,
 .Fn setnetpath
-returns NULL.
+returns
+.Dv NULL .
 .Pp
 .Fn endnetpath
-returns 0 on success and -1 on failure
-(for example, if
+returns 0 on success and \-1 on failure
+.Po
+for example, if
 .Fn setnetpath
-was not called previously).
+was not called previously
+.Pc .
 .Fn nc_perror
 or
 .Fn nc_sperror
@@ -114,10 +140,15 @@ See
 When first called,
 .Fn getnetpath
 returns a pointer to the netconfig database entry corresponding to the first
-valid NETPATH component.
-When NETPATH has been exhausted,
+valid
+.Ev NETPATH
+component.
+When
+.Ev NETPATH
+has been exhausted,
 .Fn getnetpath
-returns NULL.
+returns
+.Dv NULL .
 .Sh SEE ALSO
 .Xr getnetconfig 3 ,
 .Xr netconfig 5 ,



CVS commit: src/lib/libc/rpc

2022-12-04 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Sun Dec  4 23:02:57 UTC 2022

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

Log Message:
getnetpath(3): Sprinkle some markup


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

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



CVS commit: src/lib/libc/rpc

2022-01-04 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Tue Jan  4 22:10:09 UTC 2022

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

Log Message:
s/compnent/component/


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

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



CVS commit: src/lib/libc/rpc

2022-01-04 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Tue Jan  4 22:10:09 UTC 2022

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

Log Message:
s/compnent/component/


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/lib/libc/rpc/getnetpath.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/getnetpath.c
diff -u src/lib/libc/rpc/getnetpath.c:1.17 src/lib/libc/rpc/getnetpath.c:1.18
--- src/lib/libc/rpc/getnetpath.c:1.17	Mon Mar 11 20:19:29 2013
+++ src/lib/libc/rpc/getnetpath.c	Tue Jan  4 22:10:08 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: getnetpath.c,v 1.17 2013/03/11 20:19:29 tron Exp $	*/
+/*	$NetBSD: getnetpath.c,v 1.18 2022/01/04 22:10:08 andvar Exp $	*/
 
 /*
  * Copyright (c) 2010, Oracle America, Inc.
@@ -36,7 +36,7 @@
 #if 0
 staticchar sccsid[] = "@(#)getnetpath.c	1.11 91/12/19 SMI";
 #else
-__RCSID("$NetBSD: getnetpath.c,v 1.17 2013/03/11 20:19:29 tron Exp $");
+__RCSID("$NetBSD: getnetpath.c,v 1.18 2022/01/04 22:10:08 andvar Exp $");
 #endif
 #endif
 
@@ -140,7 +140,7 @@ setnetpath(void)
  * NULL and sets errno in case of an error (e.g., setnetpath was not called
  * previously).
  * getnetpath() silently ignores invalid NETPATH components.  A NETPATH
- * compnent is invalid if there is no corresponding entry in the netconfig
+ * component is invalid if there is no corresponding entry in the netconfig
  * database.
  * If the NETPATH variable is unset, getnetpath() behaves as if NETPATH
  * were set to the sequence of default or visible networks in the netconfig



CVS commit: src/lib/libc/rpc

2021-12-07 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Tue Dec  7 22:09:59 UTC 2021

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

Log Message:
s/listner/listener/


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 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.



CVS commit: src/lib/libc/rpc

2021-12-07 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Tue Dec  7 22:09:59 UTC 2021

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

Log Message:
s/listner/listener/


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 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.35 src/lib/libc/rpc/svc_vc.c:1.36
--- src/lib/libc/rpc/svc_vc.c:1.35	Sun Aug  8 20:54:48 2021
+++ src/lib/libc/rpc/svc_vc.c	Tue Dec  7 22:09:59 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: svc_vc.c,v 1.35 2021/08/08 20:54:48 nia Exp $	*/
+/*	$NetBSD: svc_vc.c,v 1.36 2021/12/07 22:09:59 andvar 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.35 2021/08/08 20:54:48 nia Exp $");
+__RCSID("$NetBSD: svc_vc.c,v 1.36 2021/12/07 22:09:59 andvar Exp $");
 #endif
 #endif
 
@@ -45,7 +45,7 @@ __RCSID("$NetBSD: svc_vc.c,v 1.35 2021/0
  * svc_vc.c, Server side for Connection Oriented based RPC. 
  *
  * Actually implements two flavors of transporter -
- * a tcp rendezvouser (a listner and connection establisher)
+ * a tcp rendezvouser (a listener and connection establisher)
  * and a record/tcp stream.
  */
 



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

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.



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

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.



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

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.



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-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.



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.



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-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.



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.



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

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.



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-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.



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: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.



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-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.



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-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.



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.



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.



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.



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.



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-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.



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.



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: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.



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.



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: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.



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.



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-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.



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-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.



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 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.



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.



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 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.



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: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.



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:   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.



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-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.



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:   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.



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.



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:   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.



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.



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: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.



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-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.



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

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.



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-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.



Re: CVS commit: src/lib/libc/rpc

2014-05-29 Thread Matthias Scheler
On Wed, May 28, 2014 at 10:49:28AM -0400, Christos Zoulas wrote:
 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

I don't think that this change is correct. It caused a lot of warnings
svc_tli_create: could not listen at anonymous port when my NetBSD NIS
client booted up.

I suspected that this function is also used on UDP sockets where
listen(2) will of course fail.

Kind regards

-- 
Matthias Scheler  http://zhadum.org.uk/


Re: CVS commit: src/lib/libc/rpc

2014-05-29 Thread Christos Zoulas
On May 29,  7:25am, t...@netbsd.org (Matthias Scheler) wrote:
-- Subject: Re: CVS commit: src/lib/libc/rpc

| I don't think that this change is correct. It caused a lot of warnings
| svc_tli_create: could not listen at anonymous port when my NetBSD NIS
| client booted up.
| 
| I suspected that this function is also used on UDP sockets where
| listen(2) will of course fail.
| 

Yes, you are right. Fixed!

christos


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-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.



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-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.



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.



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.



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.



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:



  1   2   >