=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/nc/netcat.c,v retrieving revision 1.87 retrieving revision 1.88 diff -c -r1.87 -r1.88 *** src/usr.bin/nc/netcat.c 2006/02/01 21:33:14 1.87 --- src/usr.bin/nc/netcat.c 2006/06/02 03:46:38 1.88 *************** *** 1,4 **** ! /* $OpenBSD: netcat.c,v 1.87 2006/02/01 21:33:14 otto Exp $ */ /* * Copyright (c) 2001 Eric Jackson * --- 1,4 ---- ! /* $OpenBSD: netcat.c,v 1.88 2006/06/02 03:46:38 ray Exp $ */ /* * Copyright (c) 2001 Eric Jackson * *************** *** 65,71 **** /* Command Line Options */ int dflag; /* detached, no stdin */ ! int iflag; /* Interval Flag */ int jflag; /* use jumbo frames if we can */ int kflag; /* More than one connect */ int lflag; /* Bind to local port */ --- 65,71 ---- /* Command Line Options */ int dflag; /* detached, no stdin */ ! unsigned int iflag; /* Interval Flag */ int jflag; /* use jumbo frames if we can */ int kflag; /* More than one connect */ int lflag; /* Bind to local port */ *************** *** 106,118 **** main(int argc, char *argv[]) { int ch, s, ret, socksv; ! char *host, *uport, *endp; struct addrinfo hints; struct servent *sv; socklen_t len; struct sockaddr_storage cliaddr; char *proxy; ! const char *proxyhost = "", *proxyport = NULL; struct addrinfo proxyhints; ret = 1; --- 106,118 ---- main(int argc, char *argv[]) { int ch, s, ret, socksv; ! char *host, *uport; struct addrinfo hints; struct servent *sv; socklen_t len; struct sockaddr_storage cliaddr; char *proxy; ! const char *errstr, *proxyhost = "", *proxyport = NULL; struct addrinfo proxyhints; ret = 1; *************** *** 120,126 **** socksv = 5; host = NULL; uport = NULL; - endp = NULL; sv = NULL; while ((ch = getopt(argc, argv, --- 120,125 ---- *************** *** 152,160 **** help(); break; case 'i': ! iflag = (int)strtoul(optarg, &endp, 10); ! if (iflag < 0 || *endp != '\0') ! errx(1, "interval cannot be negative"); break; case 'j': jflag = 1; --- 151,159 ---- help(); break; case 'i': ! iflag = strtonum(optarg, 0, UINT_MAX, &errstr); ! if (errstr) ! errx(1, "interval %s: %s", errstr, optarg); break; case 'j': jflag = 1; *************** *** 190,200 **** vflag = 1; break; case 'w': ! timeout = (int)strtoul(optarg, &endp, 10); ! if (timeout < 0 || *endp != '\0') ! errx(1, "timeout cannot be negative"); ! if (timeout >= (INT_MAX / 1000)) ! errx(1, "timeout too large"); timeout *= 1000; break; case 'x': --- 189,197 ---- vflag = 1; break; case 'w': ! timeout = strtonum(optarg, 0, INT_MAX / 1000, &errstr); ! if (errstr) ! errx(1, "timeout %s: %s", errstr, optarg); timeout *= 1000; break; case 'x': *************** *** 681,687 **** void build_ports(char *p) { ! char *n, *endp; int hi, lo, cp; int x = 0; --- 678,685 ---- void build_ports(char *p) { ! const char *errstr; ! char *n; int hi, lo, cp; int x = 0; *************** *** 693,704 **** n++; /* Make sure the ports are in order: lowest->highest. */ ! hi = (int)strtoul(n, &endp, 10); ! if (hi <= 0 || hi > PORT_MAX || *endp != '\0') ! errx(1, "port range not valid"); ! lo = (int)strtoul(p, &endp, 10); ! if (lo <= 0 || lo > PORT_MAX || *endp != '\0') ! errx(1, "port range not valid"); if (lo > hi) { cp = hi; --- 691,702 ---- n++; /* Make sure the ports are in order: lowest->highest. */ ! hi = strtonum(n, 1, PORT_MAX, &errstr); ! if (errstr) ! errx(1, "port number %s: %s", errstr, n); ! lo = strtonum(p, 1, PORT_MAX, &errstr); ! if (errstr) ! errx(1, "port number %s: %s", errstr, p); if (lo > hi) { cp = hi; *************** *** 728,736 **** } } } else { ! hi = (int)strtoul(p, &endp, 10); ! if (hi <= 0 || hi > PORT_MAX || *endp != '\0') ! errx(1, "port range not valid"); portlist[0] = calloc(1, PORT_MAX_LEN); if (portlist[0] == NULL) err(1, NULL); --- 726,734 ---- } } } else { ! hi = strtonum(p, 1, PORT_MAX, &errstr); ! if (errstr) ! errx(1, "port number %s: %s", errstr, p); portlist[0] = calloc(1, PORT_MAX_LEN); if (portlist[0] == NULL) err(1, NULL);