summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/libc/rpc/clnt_tcp.c7
-rw-r--r--lib/libc/rpc/clnt_udp.c7
-rw-r--r--lib/libc/rpc/pmap_rmt.c7
-rw-r--r--lib/libc/rpc/svc.c36
-rw-r--r--lib/libc/rpc/svc_run.c9
-rw-r--r--lib/libc/rpc/svc_tcp.c7
6 files changed, 45 insertions, 28 deletions
diff --git a/lib/libc/rpc/clnt_tcp.c b/lib/libc/rpc/clnt_tcp.c
index f76cf0203ab..e8c65ecabf0 100644
--- a/lib/libc/rpc/clnt_tcp.c
+++ b/lib/libc/rpc/clnt_tcp.c
@@ -28,7 +28,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char *rcsid = "$OpenBSD: clnt_tcp.c,v 1.6 1996/08/19 08:31:29 tholo Exp $";
+static char *rcsid = "$OpenBSD: clnt_tcp.c,v 1.7 1996/08/20 23:47:37 deraadt Exp $";
#endif /* LIBC_SCCS and not lint */
/*
@@ -407,10 +407,11 @@ readtcp(ct, buf, len)
return (0);
if (ct->ct_sock+1 > FD_SETSIZE) {
- fds = (fd_set *)malloc(howmany(ct->ct_sock+1, NBBY));
+ int bytes = howmany(ct->ct_sock+1, NFDBITS) * sizeof(fd_mask);
+ fds = (fd_set *)malloc(bytes);
if (fds == NULL)
return (-1);
- memset(fds, '\0', howmany(ct->ct_sock+1, NBBY));
+ memset(fds, 0, bytes);
} else {
fds = &readfds;
FD_ZERO(fds);
diff --git a/lib/libc/rpc/clnt_udp.c b/lib/libc/rpc/clnt_udp.c
index fec0c0e0ee1..ee88b1c4c18 100644
--- a/lib/libc/rpc/clnt_udp.c
+++ b/lib/libc/rpc/clnt_udp.c
@@ -28,7 +28,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char *rcsid = "$OpenBSD: clnt_udp.c,v 1.6 1996/08/19 08:31:30 tholo Exp $";
+static char *rcsid = "$OpenBSD: clnt_udp.c,v 1.7 1996/08/20 23:47:40 deraadt Exp $";
#endif /* LIBC_SCCS and not lint */
/*
@@ -234,10 +234,11 @@ clntudp_call(cl, proc, xargs, argsp, xresults, resultsp, utimeout)
timeout = cu->cu_total; /* use default timeout */
if (cu->cu_sock+1 > FD_SETSIZE) {
- fds = (fd_set *)malloc(howmany(cu->cu_sock+1, NBBY));
+ int bytes = howmany(cu->cu_sock+1, NFDBITS) * sizeof(fd_mask);
+ fds = (fd_set *)malloc(bytes);
if (fds == NULL)
return (cu->cu_error.re_status = RPC_CANTSEND);
- memset(fds, '\0', howmany(cu->cu_sock+1, NBBY));
+ memset(fds, 0, bytes);
} else {
fds = &readfds;
FD_ZERO(fds);
diff --git a/lib/libc/rpc/pmap_rmt.c b/lib/libc/rpc/pmap_rmt.c
index ab5624132a6..68dab474cb9 100644
--- a/lib/libc/rpc/pmap_rmt.c
+++ b/lib/libc/rpc/pmap_rmt.c
@@ -28,7 +28,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char *rcsid = "$OpenBSD: pmap_rmt.c,v 1.7 1996/08/19 08:31:42 tholo Exp $";
+static char *rcsid = "$OpenBSD: pmap_rmt.c,v 1.8 1996/08/20 23:47:42 deraadt Exp $";
#endif /* LIBC_SCCS and not lint */
/*
@@ -257,12 +257,13 @@ clnt_broadcast(prog, vers, proc, xargs, argsp, xresults, resultsp, eachresult)
#endif /* def SO_BROADCAST */
if (sock+1 > FD_SETSIZE) {
- fds = (fd_set *)malloc(howmany(sock+1, NBBY));
+ int bytes = howmany(sock+1, NFDBITS) * sizeof(fd_mask);
+ fds = (fd_set *)malloc(bytes);
if (fds == NULL) {
stat = RPC_CANTSEND;
goto done_broad;
}
- memset(fds, '\0', howmany(sock+1, NBBY));
+ memset(fds, 0, bytes);
} else {
fds = &readfds;
FD_ZERO(fds);
diff --git a/lib/libc/rpc/svc.c b/lib/libc/rpc/svc.c
index 403183fc2e2..cce02dbbf3a 100644
--- a/lib/libc/rpc/svc.c
+++ b/lib/libc/rpc/svc.c
@@ -28,7 +28,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char *rcsid = "$OpenBSD: svc.c,v 1.6 1996/08/19 08:31:51 tholo Exp $";
+static char *rcsid = "$OpenBSD: svc.c,v 1.7 1996/08/20 23:47:43 deraadt Exp $";
#endif /* LIBC_SCCS and not lint */
/*
@@ -49,6 +49,7 @@ static char *rcsid = "$OpenBSD: svc.c,v 1.6 1996/08/19 08:31:51 tholo Exp $";
#include <rpc/pmap_clnt.h>
static SVCXPRT **xports;
+static int xportssize;
#define NULL_SVC ((struct svc_callout *)0)
#define RQCRED_SIZE 400 /* this size is excessive */
@@ -84,29 +85,40 @@ xprt_register(xprt)
{
register int sock = xprt->xp_sock;
- if (xports == NULL) {
- xports = (SVCXPRT **)mem_alloc(FD_SETSIZE *
- sizeof(SVCXPRT *));
- memset(xports, '\0', FD_SETSIZE * sizeof(SVCXPRT *));
- }
-
if (sock+1 > __svc_fdsetsize) {
+ int bytes = howmany(sock+1, NFDBITS) * sizeof(fd_mask);
fd_set *fds;
- fds = (fd_set *)malloc(howmany(sock+1, NBBY));
- memset(fds, '\0', howmany(sock+1, NBBY));
+ fds = (fd_set *)malloc(bytes);
+ memset(fds, 0, bytes);
if (__svc_fdset) {
- memcpy(fds, __svc_fdset,
- howmany(__svc_fdsetsize, NBBY));
+ memcpy(fds, __svc_fdset, howmany(__svc_fdsetsize,
+ NFDBITS) * sizeof(fd_mask));
free(__svc_fdset);
}
__svc_fdset = fds;
- __svc_fdsetsize = sock+1;
+ __svc_fdsetsize = howmany(sock+1, NFDBITS);
}
if (sock < FD_SETSIZE)
FD_SET(sock, &svc_fdset);
FD_SET(sock, __svc_fdset);
+
+ if (xports == NULL || sock+1 > xportssize) {
+ SVCXPRT **xp;
+ int size = FD_SETSIZE;
+
+ if (sock+1 > size)
+ size = sock+1;
+ xp = (SVCXPRT **)mem_alloc(size * sizeof(SVCXPRT *));
+ memset(xp, 0, size * sizeof(SVCXPRT *));
+ if (xports) {
+ memcpy(xp, xports, xportssize * sizeof(SVCXPRT *));
+ free(xports);
+ }
+ xportssize = size;
+ xports = xp;
+ }
xports[sock] = xprt;
svc_maxfd = max(svc_maxfd, sock);
}
diff --git a/lib/libc/rpc/svc_run.c b/lib/libc/rpc/svc_run.c
index 326d062c3a8..6923dae5c9e 100644
--- a/lib/libc/rpc/svc_run.c
+++ b/lib/libc/rpc/svc_run.c
@@ -28,7 +28,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char *rcsid = "$OpenBSD: svc_run.c,v 1.6 1996/08/20 20:01:56 deraadt Exp $";
+static char *rcsid = "$OpenBSD: svc_run.c,v 1.7 1996/08/20 23:47:44 deraadt Exp $";
#endif /* LIBC_SCCS and not lint */
/*
@@ -49,9 +49,10 @@ svc_run()
for (;;) {
if (__svc_fdset) {
- fds = (fd_set *)malloc(howmany(__svc_fdsetsize, NBBY));
- memcpy(fds, __svc_fdset, howmany(__svc_fdsetsize,
- NBBY));
+ int bytes = howmany(__svc_fdsetsize, NFDBITS) *
+ sizeof(fd_mask);
+ fds = (fd_set *)malloc(bytes);
+ memcpy(fds, __svc_fdset, bytes);
} else
fds = NULL;
switch (select(svc_maxfd+1, fds, 0, 0, (struct timeval *)0)) {
diff --git a/lib/libc/rpc/svc_tcp.c b/lib/libc/rpc/svc_tcp.c
index 4482f06d459..e9bf8d440b0 100644
--- a/lib/libc/rpc/svc_tcp.c
+++ b/lib/libc/rpc/svc_tcp.c
@@ -28,7 +28,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char *rcsid = "$OpenBSD: svc_tcp.c,v 1.6 1996/08/19 08:31:57 tholo Exp $";
+static char *rcsid = "$OpenBSD: svc_tcp.c,v 1.7 1996/08/20 23:47:46 deraadt Exp $";
#endif /* LIBC_SCCS and not lint */
/*
@@ -307,10 +307,11 @@ readtcp(xprt, buf, len)
fd_set *fds, readfds;
if (sock+1 > FD_SETSIZE) {
- fds = (fd_set *)malloc(howmany(sock+1, NBBY));
+ int bytes = howmany(sock+1, NFDBITS) * sizeof(fd_mask);
+ fds = (fd_set *)malloc(bytes);
if (fds == NULL)
goto fatal_err;
- memset(fds, '\0', howmany(sock+1, NBBY));
+ memset(fds, 0, bytes);
} else {
fds = &readfds;
FD_ZERO(fds);