summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorderaadt <deraadt@openbsd.org>1997-11-04 07:40:51 +0000
committerderaadt <deraadt@openbsd.org>1997-11-04 07:40:51 +0000
commit5af590702dd9d4d563997cc59400cad4a369fb0a (patch)
treeed0127d5b7c48243ae4bb9f0c70f7c2e0b767ee9
parentdon't try function #21 for floppies (diff)
downloadwireguard-openbsd-5af590702dd9d4d563997cc59400cad4a369fb0a.tar.xz
wireguard-openbsd-5af590702dd9d4d563997cc59400cad4a369fb0a.zip
ensure we got a reserved port
-rw-r--r--usr.sbin/ypserv/yppush/yppush.c18
-rw-r--r--usr.sbin/ypserv/ypserv/ypserv.c12
2 files changed, 22 insertions, 8 deletions
diff --git a/usr.sbin/ypserv/yppush/yppush.c b/usr.sbin/ypserv/yppush/yppush.c
index aac2f7485d8..c199f754d2c 100644
--- a/usr.sbin/ypserv/yppush/yppush.c
+++ b/usr.sbin/ypserv/yppush/yppush.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: yppush.c,v 1.7 1997/05/01 22:14:46 niklas Exp $ */
+/* $OpenBSD: yppush.c,v 1.8 1997/11/04 07:40:51 deraadt Exp $ */
/*
* Copyright (c) 1995 Mats O Jansson <moj@stacken.kth.se>
@@ -32,7 +32,7 @@
*/
#ifndef lint
-static char rcsid[] = "$OpenBSD: yppush.c,v 1.7 1997/05/01 22:14:46 niklas Exp $";
+static char rcsid[] = "$OpenBSD: yppush.c,v 1.8 1997/11/04 07:40:51 deraadt Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -172,10 +172,15 @@ char *indata;
fprintf(stderr, "yppush: Cannot create callback transport.\n");
return;
}
+ if (transp->xp_port >= IPPORT_RESERVED) {
+ svcudp_destroy(transp);
+ fprintf(stderr, "yppush: Cannot allocate reserved port.\n");
+ return;
+ }
for (prog=0x40000000; prog<0x5fffffff; prog++) {
if (sts = svc_register(transp, prog, 1,
- yppush_xfrrespprog_1, IPPROTO_UDP))
+ yppush_xfrrespprog_1, IPPROTO_UDP))
break;
}
@@ -193,12 +198,13 @@ char *indata;
exit(0);
default:
close(transp->xp_sock);
+ transp->xp_sock = -1;
req_xfr(pid, prog, transp, host, client);
wait4(pid, &status, 0, &res);
svc_unregister(prog, 1);
- if (client != NULL) {
- clnt_destroy(client);
- }
+ if (client != NULL)
+ clnt_destroy(client);
+ /* XXX transp leak? */
}
}
diff --git a/usr.sbin/ypserv/ypserv/ypserv.c b/usr.sbin/ypserv/ypserv/ypserv.c
index 8277d5dd3b5..9ef53a15d4a 100644
--- a/usr.sbin/ypserv/ypserv/ypserv.c
+++ b/usr.sbin/ypserv/ypserv/ypserv.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ypserv.c,v 1.11 1997/08/05 05:09:33 deraadt Exp $ */
+/* $OpenBSD: ypserv.c,v 1.12 1997/11/04 07:40:52 deraadt Exp $ */
/*
* Copyright (c) 1994 Mats O Jansson <moj@stacken.kth.se>
@@ -32,7 +32,7 @@
*/
#ifndef LINT
-static char rcsid[] = "$OpenBSD: ypserv.c,v 1.11 1997/08/05 05:09:33 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: ypserv.c,v 1.12 1997/11/04 07:40:52 deraadt Exp $";
#endif
#include "yp.h"
@@ -452,6 +452,10 @@ char *argv[];
_msgout("cannot create udp service.");
exit(1);
}
+ if (transp->xp_port >= IPPORT_RESERVED) {
+ _msgout("cannot allocate udp privileged port.");
+ exit(1);
+ }
if (!_rpcpmstart)
proto = IPPROTO_UDP;
if (allowv1) {
@@ -475,6 +479,10 @@ char *argv[];
_msgout("cannot create tcp service.");
exit(1);
}
+ if (transp->xp_port >= IPPORT_RESERVED) {
+ _msgout("cannot allocate tcp privileged port.");
+ exit(1);
+ }
if (!_rpcpmstart)
proto = IPPROTO_TCP;
if (allowv1) {