7d95763414
Split up the ubuntu patch OBS-URL: https://build.opensuse.org/request/show/197181 OBS-URL: https://build.opensuse.org/package/show/network:utilities/netcat-openbsd?expand=0&rev=12
108 lines
2.8 KiB
Diff
108 lines
2.8 KiB
Diff
Index: netcat-openbsd-1.89/netcat.c
|
|
===================================================================
|
|
--- netcat-openbsd-1.89.orig/netcat.c 2008-01-22 16:17:17.000000000 -0500
|
|
+++ netcat-openbsd-1.89/netcat.c 2008-01-22 16:17:18.000000000 -0500
|
|
@@ -67,7 +67,7 @@
|
|
|
|
/* Command Line Options */
|
|
int dflag; /* detached, no stdin */
|
|
-unsigned int iflag; /* Interval Flag */
|
|
+int iflag; /* Interval Flag */
|
|
int jflag; /* use jumbo frames if we can */
|
|
int kflag; /* More than one connect */
|
|
int lflag; /* Bind to local port */
|
|
@@ -108,13 +108,13 @@
|
|
main(int argc, char *argv[])
|
|
{
|
|
int ch, s, ret, socksv;
|
|
- char *host, *uport;
|
|
+ char *host, *uport, *endp;
|
|
struct addrinfo hints;
|
|
struct servent *sv;
|
|
socklen_t len;
|
|
struct sockaddr_storage cliaddr;
|
|
char *proxy;
|
|
- const char *errstr, *proxyhost = "", *proxyport = NULL;
|
|
+ const char *proxyhost = "", *proxyport = NULL;
|
|
struct addrinfo proxyhints;
|
|
|
|
ret = 1;
|
|
@@ -122,6 +122,7 @@
|
|
socksv = 5;
|
|
host = NULL;
|
|
uport = NULL;
|
|
+ endp = NULL;
|
|
sv = NULL;
|
|
|
|
while ((ch = getopt(argc, argv,
|
|
@@ -153,9 +154,9 @@
|
|
help();
|
|
break;
|
|
case 'i':
|
|
- iflag = strtonum(optarg, 0, UINT_MAX, &errstr);
|
|
- if (errstr)
|
|
- errx(1, "interval %s: %s", errstr, optarg);
|
|
+ iflag = (int)strtoul(optarg, &endp, 10);
|
|
+ if (iflag < 0 || *endp != '\0')
|
|
+ errx(1, "interval cannot be negative");
|
|
break;
|
|
case 'j':
|
|
jflag = 1;
|
|
@@ -191,9 +192,11 @@
|
|
vflag = 1;
|
|
break;
|
|
case 'w':
|
|
- timeout = strtonum(optarg, 0, INT_MAX / 1000, &errstr);
|
|
- if (errstr)
|
|
- errx(1, "timeout %s: %s", errstr, optarg);
|
|
+ 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':
|
|
@@ -680,8 +683,7 @@
|
|
void
|
|
build_ports(char *p)
|
|
{
|
|
- const char *errstr;
|
|
- char *n;
|
|
+ char *n, *endp;
|
|
int hi, lo, cp;
|
|
int x = 0;
|
|
|
|
@@ -693,12 +695,12 @@
|
|
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);
|
|
+ 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;
|
|
@@ -729,9 +731,9 @@
|
|
}
|
|
}
|
|
} else {
|
|
- hi = strtonum(p, 1, PORT_MAX, &errstr);
|
|
- if (errstr)
|
|
- errx(1, "port number %s: %s", errstr, p);
|
|
+ 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);
|