Mon Mar 16 02:20:02 2009 UTC ()
fix sign-compare issue


(lukem)
diff -r1.46 -r1.47 src/libexec/rshd/rshd.c

cvs diff -r1.46 -r1.47 src/libexec/rshd/rshd.c (expand / switch to unified diff)

--- src/libexec/rshd/rshd.c 2008/07/20 01:09:07 1.46
+++ src/libexec/rshd/rshd.c 2009/03/16 02:20:02 1.47
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: rshd.c,v 1.46 2008/07/20 01:09:07 lukem Exp $ */ 1/* $NetBSD: rshd.c,v 1.47 2009/03/16 02:20:02 lukem Exp $ */
2 2
3/* 3/*
4 * Copyright (C) 1998 WIDE Project. 4 * Copyright (C) 1998 WIDE Project.
5 * All rights reserved. 5 * All rights reserved.
6 *  6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -59,27 +59,27 @@ @@ -59,27 +59,27 @@
59 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 59 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
60 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 60 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
61 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 61 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
62 * SUCH DAMAGE. 62 * SUCH DAMAGE.
63 */ 63 */
64 64
65#include <sys/cdefs.h> 65#include <sys/cdefs.h>
66#ifndef lint 66#ifndef lint
67__COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1992, 1993, 1994\ 67__COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1992, 1993, 1994\
68 The Regents of the University of California. All rights reserved."); 68 The Regents of the University of California. All rights reserved.");
69#if 0 69#if 0
70static char sccsid[] = "@(#)rshd.c 8.2 (Berkeley) 4/6/94"; 70static char sccsid[] = "@(#)rshd.c 8.2 (Berkeley) 4/6/94";
71#else 71#else
72__RCSID("$NetBSD: rshd.c,v 1.46 2008/07/20 01:09:07 lukem Exp $"); 72__RCSID("$NetBSD: rshd.c,v 1.47 2009/03/16 02:20:02 lukem Exp $");
73#endif 73#endif
74#endif /* not lint */ 74#endif /* not lint */
75 75
76/* 76/*
77 * remote shell server: 77 * remote shell server:
78 * [port]\0 78 * [port]\0
79 * remuser\0 79 * remuser\0
80 * locuser\0 80 * locuser\0
81 * command\0 81 * command\0
82 * data 82 * data
83 */ 83 */
84#include <sys/param.h> 84#include <sys/param.h>
85#include <sys/ioctl.h> 85#include <sys/ioctl.h>
@@ -299,27 +299,28 @@ doit(struct sockaddr *fromp) @@ -299,27 +299,28 @@ doit(struct sockaddr *fromp)
299 syslog(LOG_ERR, "malformed \"from\" address (af %d)", af); 299 syslog(LOG_ERR, "malformed \"from\" address (af %d)", af);
300 exit(EXIT_FAILURE); 300 exit(EXIT_FAILURE);
301 } 301 }
302 if (getnameinfo(fromp, fromp->sa_len, naddr, sizeof(naddr), 302 if (getnameinfo(fromp, fromp->sa_len, naddr, sizeof(naddr),
303 pbuf, sizeof(pbuf), niflags) != 0) { 303 pbuf, sizeof(pbuf), niflags) != 0) {
304 syslog(LOG_ERR, "malformed \"from\" address (af %d)", af); 304 syslog(LOG_ERR, "malformed \"from\" address (af %d)", af);
305 exit(EXIT_FAILURE); 305 exit(EXIT_FAILURE);
306 } 306 }
307#ifdef IP_OPTIONS 307#ifdef IP_OPTIONS
308 if (af == AF_INET) { 308 if (af == AF_INET) {
309 309
310 u_char optbuf[BUFSIZ/3]; 310 u_char optbuf[BUFSIZ/3];
311 socklen_t optsize = sizeof(optbuf); 311 socklen_t optsize = sizeof(optbuf);
312 int ipproto, i; 312 int ipproto;
 313 unsigned int i;
313 struct protoent *ip; 314 struct protoent *ip;
314 315
315 if ((ip = getprotobyname("ip")) != NULL) 316 if ((ip = getprotobyname("ip")) != NULL)
316 ipproto = ip->p_proto; 317 ipproto = ip->p_proto;
317 else 318 else
318 ipproto = IPPROTO_IP; 319 ipproto = IPPROTO_IP;
319 if (!getsockopt(0, ipproto, IP_OPTIONS, (char *)optbuf, &optsize) && 320 if (!getsockopt(0, ipproto, IP_OPTIONS, (char *)optbuf, &optsize) &&
320 optsize != 0) { 321 optsize != 0) {
321 for (i = 0; i < optsize;) { 322 for (i = 0; i < optsize;) {
322 u_char c = optbuf[i]; 323 u_char c = optbuf[i];
323 if (c == IPOPT_LSRR || c == IPOPT_SSRR) { 324 if (c == IPOPT_LSRR || c == IPOPT_SSRR) {
324 syslog(LOG_NOTICE, 325 syslog(LOG_NOTICE,
325 "Connection refused from %s " 326 "Connection refused from %s "