From 82c44d0cd94b4f8da502a273fc2526908ff22550 Mon Sep 17 00:00:00 2001 From: deraadt Date: Thu, 13 Feb 1997 22:29:07 +0000 Subject: [PATCH] option handling is a bitch --- lib/libc/rpc/svc_tcp.c | 5 +++-- libexec/rlogind/rlogind.c | 5 +++-- libexec/rshd/rshd.c | 5 +++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/lib/libc/rpc/svc_tcp.c b/lib/libc/rpc/svc_tcp.c index eb406395ad7..c755ab1a892 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.9 1997/02/13 22:21:11 deraadt Exp $"; +static char *rcsid = "$OpenBSD: svc_tcp.c,v 1.10 1997/02/13 22:29:12 deraadt Exp $"; #endif /* LIBC_SCCS and not lint */ /* @@ -254,7 +254,8 @@ rendezvous_request(xprt) if (!getsockopt(sock, IPPROTO_IP, IP_OPTIONS, (char *)&opts, &optsize) && optsize != 0) { - for (i = 0; i < optsize; ) { + for (i = 0; (void *)&opts.ipopt_list[i] - (void *)&opts < + sizeof opts; ) { u_char c = (u_char)opts.ipopt_list[i]; if (c == IPOPT_LSRR || c == IPOPT_SSRR) { close(sock); diff --git a/libexec/rlogind/rlogind.c b/libexec/rlogind/rlogind.c index 42670479b48..1d2ee6f20b8 100644 --- a/libexec/rlogind/rlogind.c +++ b/libexec/rlogind/rlogind.c @@ -39,7 +39,7 @@ static char copyright[] = #ifndef lint /* from: static char sccsid[] = "@(#)rlogind.c 8.1 (Berkeley) 6/4/93"; */ -static char *rcsid = "$Id: rlogind.c,v 1.17 1997/02/13 22:21:10 deraadt Exp $"; +static char *rcsid = "$Id: rlogind.c,v 1.18 1997/02/13 22:29:10 deraadt Exp $"; #endif /* not lint */ /* @@ -269,7 +269,8 @@ doit(f, fromp) ipproto = IPPROTO_IP; if (getsockopt(0, ipproto, IP_OPTIONS, (char *)&opts, &optsize) == 0 && optsize != 0) { - for (i = 0; i < optsize; ) { + for (i = 0; (void *)&opts.ipopt_list[i] - (void *)&opts < + sizeof opts; ) { u_char c = (u_char)opts.ipopt_list[i]; if (c == IPOPT_LSRR || c == IPOPT_SSRR) exit(1); diff --git a/libexec/rshd/rshd.c b/libexec/rshd/rshd.c index c4ab99d8c9a..8575b2ee483 100644 --- a/libexec/rshd/rshd.c +++ b/libexec/rshd/rshd.c @@ -39,7 +39,7 @@ static char copyright[] = #ifndef lint /* from: static char sccsid[] = "@(#)rshd.c 8.2 (Berkeley) 4/6/94"; */ -static char *rcsid = "$Id: rshd.c,v 1.14 1997/02/13 22:21:08 deraadt Exp $"; +static char *rcsid = "$Id: rshd.c,v 1.15 1997/02/13 22:29:07 deraadt Exp $"; #endif /* not lint */ /* @@ -249,7 +249,8 @@ doit(fromp) ipproto = IPPROTO_IP; if (!getsockopt(0, ipproto, IP_OPTIONS, (char *)&opts, &optsize) && optsize != 0) { - for (i = 0; i < optsize; ) { + for (i = 0; (void *)&opts.ipopt_list[i] - (void *)&opts < + sizeof opts; ) { u_char c = (u_char)opts.ipopt_list[i]; if (c == IPOPT_LSRR || c == IPOPT_SSRR) exit(1); -- 2.20.1