From: deraadt Date: Thu, 13 Feb 1997 22:21:08 +0000 (+0000) Subject: ok, i finally learned about struct ipoption X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=3d46f30246438483283086fc9797f9519b13d6f4;p=openbsd ok, i finally learned about struct ipoption --- diff --git a/lib/libc/rpc/svc_tcp.c b/lib/libc/rpc/svc_tcp.c index 0fac0993df6..eb406395ad7 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.8 1997/02/07 06:27:19 deraadt Exp $"; +static char *rcsid = "$OpenBSD: svc_tcp.c,v 1.9 1997/02/13 22:21:11 deraadt Exp $"; #endif /* LIBC_SCCS and not lint */ /* @@ -52,6 +52,7 @@ static char *rcsid = "$OpenBSD: svc_tcp.c,v 1.8 1997/02/07 06:27:19 deraadt Exp #include #include #include +#include /* * Ops vector for TCP/IP based rpc service handle @@ -248,20 +249,21 @@ rendezvous_request(xprt) #ifdef IP_OPTIONS { - u_char optbuf[BUFSIZ/3]; - int optsize = sizeof(optbuf), i; + struct ipoption opts; + int optsize = sizeof(opts), i; - if (!getsockopt(sock, IPPROTO_IP, IP_OPTIONS, (char *)optbuf, + if (!getsockopt(sock, IPPROTO_IP, IP_OPTIONS, (char *)&opts, &optsize) && optsize != 0) { for (i = 0; i < optsize; ) { - u_char c = optbuf[i]; + u_char c = (u_char)opts.ipopt_list[i]; if (c == IPOPT_LSRR || c == IPOPT_SSRR) { close(sock); goto again; } if (c == IPOPT_EOL) break; - i += (c == IPOPT_NOP) ? 1 : optbuf[i+1]; + i += (c == IPOPT_NOP) ? 1 : + (u_char)opts.ipopt_list[i+1]; } } } diff --git a/libexec/rlogind/rlogind.c b/libexec/rlogind/rlogind.c index 30f366f6507..42670479b48 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.16 1997/02/05 21:09:30 deraadt Exp $"; +static char *rcsid = "$Id: rlogind.c,v 1.17 1997/02/13 22:21:10 deraadt Exp $"; #endif /* not lint */ /* @@ -62,6 +62,7 @@ static char *rcsid = "$Id: rlogind.c,v 1.16 1997/02/05 21:09:30 deraadt Exp $"; #include #include #include +#include #include #include @@ -258,23 +259,24 @@ doit(f, fromp) } #ifdef IP_OPTIONS { - u_char optbuf[BUFSIZ/3]; - int optsize = sizeof(optbuf), ipproto, i; + struct ipoption opts; + int optsize = sizeof(opts), ipproto, i; struct protoent *ip; if ((ip = getprotobyname("ip")) != NULL) ipproto = ip->p_proto; else ipproto = IPPROTO_IP; - if (getsockopt(0, ipproto, IP_OPTIONS, (char *)optbuf, + if (getsockopt(0, ipproto, IP_OPTIONS, (char *)&opts, &optsize) == 0 && optsize != 0) { for (i = 0; i < optsize; ) { - u_char c = optbuf[i]; + u_char c = (u_char)opts.ipopt_list[i]; if (c == IPOPT_LSRR || c == IPOPT_SSRR) exit(1); if (c == IPOPT_EOL) break; - i += (c == IPOPT_NOP) ? 1 : optbuf[i+1]; + i += (c == IPOPT_NOP) ? 1 : + (u_char)opts.ipopt_list[i+1]; } } } diff --git a/libexec/rshd/rshd.c b/libexec/rshd/rshd.c index 2ac2bf24ccb..c4ab99d8c9a 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.13 1997/02/05 21:09:29 deraadt Exp $"; +static char *rcsid = "$Id: rshd.c,v 1.14 1997/02/13 22:21:08 deraadt Exp $"; #endif /* not lint */ /* @@ -58,6 +58,7 @@ static char *rcsid = "$Id: rshd.c,v 1.13 1997/02/05 21:09:29 deraadt Exp $"; #include #include #include +#include #include #include @@ -238,23 +239,23 @@ doit(fromp) } #ifdef IP_OPTIONS { - u_char optbuf[BUFSIZ/3]; - int optsize = sizeof(optbuf), ipproto, i; + struct ipoption opts; + int optsize = sizeof(opts), ipproto, i; struct protoent *ip; if ((ip = getprotobyname("ip")) != NULL) ipproto = ip->p_proto; else ipproto = IPPROTO_IP; - if (!getsockopt(0, ipproto, IP_OPTIONS, (char *)optbuf, &optsize) && + if (!getsockopt(0, ipproto, IP_OPTIONS, (char *)&opts, &optsize) && optsize != 0) { for (i = 0; i < optsize; ) { - u_char c = optbuf[i]; + u_char c = (u_char)opts.ipopt_list[i]; if (c == IPOPT_LSRR || c == IPOPT_SSRR) exit(1); if (c == IPOPT_EOL) break; - i += (c == IPOPT_NOP) ? 1 : optbuf[i+1]; + i += (c == IPOPT_NOP) ? 1 : (u_char)opts.ipopt_list[i+1]; } } }