diff options
author | nicm <> | 2010-04-20 07:26:35 +0000 |
---|---|---|
committer | nicm <> | 2010-04-20 07:26:35 +0000 |
commit | edd577d03c252c183c5bca6663fee156512d5a12 (patch) | |
tree | 3756288ca74591c95b49fad597088a95e9216f29 | |
parent | 9566d97d91fecf6448578e21116b0bc95b9a5e0c (diff) | |
download | openbsd-edd577d03c252c183c5bca6663fee156512d5a12.tar.gz openbsd-edd577d03c252c183c5bca6663fee156512d5a12.tar.bz2 openbsd-edd577d03c252c183c5bca6663fee156512d5a12.zip |
Allocate the port number properly (don't allocate space then ignore it),
and use %zu for size_t.
ok djm
-rw-r--r-- | src/usr.bin/nc/netcat.c | 5 | ||||
-rw-r--r-- | src/usr.bin/nc/socks.c | 18 |
2 files changed, 11 insertions, 12 deletions
diff --git a/src/usr.bin/nc/netcat.c b/src/usr.bin/nc/netcat.c index 508712388d..3c845966bd 100644 --- a/src/usr.bin/nc/netcat.c +++ b/src/usr.bin/nc/netcat.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: netcat.c,v 1.95 2010/02/27 00:58:56 nicm Exp $ */ | 1 | /* $OpenBSD: netcat.c,v 1.96 2010/04/20 07:26:34 nicm Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2001 Eric Jackson <ericj@monkey.org> | 3 | * Copyright (c) 2001 Eric Jackson <ericj@monkey.org> |
4 | * | 4 | * |
@@ -766,10 +766,9 @@ build_ports(char *p) | |||
766 | hi = strtonum(p, 1, PORT_MAX, &errstr); | 766 | hi = strtonum(p, 1, PORT_MAX, &errstr); |
767 | if (errstr) | 767 | if (errstr) |
768 | errx(1, "port number %s: %s", errstr, p); | 768 | errx(1, "port number %s: %s", errstr, p); |
769 | portlist[0] = calloc(1, PORT_MAX_LEN); | 769 | portlist[0] = strdup(p); |
770 | if (portlist[0] == NULL) | 770 | if (portlist[0] == NULL) |
771 | err(1, NULL); | 771 | err(1, NULL); |
772 | portlist[0] = p; | ||
773 | } | 772 | } |
774 | } | 773 | } |
775 | 774 | ||
diff --git a/src/usr.bin/nc/socks.c b/src/usr.bin/nc/socks.c index da7bd0c60e..b38dff741e 100644 --- a/src/usr.bin/nc/socks.c +++ b/src/usr.bin/nc/socks.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: socks.c,v 1.17 2006/09/25 04:51:20 ray Exp $ */ | 1 | /* $OpenBSD: socks.c,v 1.18 2010/04/20 07:26:35 nicm Exp $ */ |
2 | 2 | ||
3 | /* | 3 | /* |
4 | * Copyright (c) 1999 Niklas Hallqvist. All rights reserved. | 4 | * Copyright (c) 1999 Niklas Hallqvist. All rights reserved. |
@@ -167,11 +167,11 @@ socks_connect(const char *host, const char *port, | |||
167 | buf[2] = SOCKS_NOAUTH; | 167 | buf[2] = SOCKS_NOAUTH; |
168 | cnt = atomicio(vwrite, proxyfd, buf, 3); | 168 | cnt = atomicio(vwrite, proxyfd, buf, 3); |
169 | if (cnt != 3) | 169 | if (cnt != 3) |
170 | err(1, "write failed (%d/3)", cnt); | 170 | err(1, "write failed (%zu/3)", cnt); |
171 | 171 | ||
172 | cnt = atomicio(read, proxyfd, buf, 2); | 172 | cnt = atomicio(read, proxyfd, buf, 2); |
173 | if (cnt != 2) | 173 | if (cnt != 2) |
174 | err(1, "read failed (%d/3)", cnt); | 174 | err(1, "read failed (%zu/3)", cnt); |
175 | 175 | ||
176 | if (buf[1] == SOCKS_NOMETHOD) | 176 | if (buf[1] == SOCKS_NOMETHOD) |
177 | errx(1, "authentication method negotiation failed"); | 177 | errx(1, "authentication method negotiation failed"); |
@@ -220,11 +220,11 @@ socks_connect(const char *host, const char *port, | |||
220 | 220 | ||
221 | cnt = atomicio(vwrite, proxyfd, buf, wlen); | 221 | cnt = atomicio(vwrite, proxyfd, buf, wlen); |
222 | if (cnt != wlen) | 222 | if (cnt != wlen) |
223 | err(1, "write failed (%d/%d)", cnt, wlen); | 223 | err(1, "write failed (%zu/%zu)", cnt, wlen); |
224 | 224 | ||
225 | cnt = atomicio(read, proxyfd, buf, 10); | 225 | cnt = atomicio(read, proxyfd, buf, 10); |
226 | if (cnt != 10) | 226 | if (cnt != 10) |
227 | err(1, "read failed (%d/10)", cnt); | 227 | err(1, "read failed (%zu/10)", cnt); |
228 | if (buf[1] != 0) | 228 | if (buf[1] != 0) |
229 | errx(1, "connection failed, SOCKS error %d", buf[1]); | 229 | errx(1, "connection failed, SOCKS error %d", buf[1]); |
230 | } else if (socksv == 4) { | 230 | } else if (socksv == 4) { |
@@ -242,11 +242,11 @@ socks_connect(const char *host, const char *port, | |||
242 | 242 | ||
243 | cnt = atomicio(vwrite, proxyfd, buf, wlen); | 243 | cnt = atomicio(vwrite, proxyfd, buf, wlen); |
244 | if (cnt != wlen) | 244 | if (cnt != wlen) |
245 | err(1, "write failed (%d/%d)", cnt, wlen); | 245 | err(1, "write failed (%zu/%zu)", cnt, wlen); |
246 | 246 | ||
247 | cnt = atomicio(read, proxyfd, buf, 8); | 247 | cnt = atomicio(read, proxyfd, buf, 8); |
248 | if (cnt != 8) | 248 | if (cnt != 8) |
249 | err(1, "read failed (%d/8)", cnt); | 249 | err(1, "read failed (%zu/8)", cnt); |
250 | if (buf[1] != 90) | 250 | if (buf[1] != 90) |
251 | errx(1, "connection failed, SOCKS error %d", buf[1]); | 251 | errx(1, "connection failed, SOCKS error %d", buf[1]); |
252 | } else if (socksv == -1) { | 252 | } else if (socksv == -1) { |
@@ -272,7 +272,7 @@ socks_connect(const char *host, const char *port, | |||
272 | 272 | ||
273 | cnt = atomicio(vwrite, proxyfd, buf, r); | 273 | cnt = atomicio(vwrite, proxyfd, buf, r); |
274 | if (cnt != r) | 274 | if (cnt != r) |
275 | err(1, "write failed (%d/%d)", cnt, r); | 275 | err(1, "write failed (%zu/%d)", cnt, r); |
276 | 276 | ||
277 | if (authretry > 1) { | 277 | if (authretry > 1) { |
278 | char resp[1024]; | 278 | char resp[1024]; |
@@ -290,7 +290,7 @@ socks_connect(const char *host, const char *port, | |||
290 | errx(1, "Proxy auth response too long"); | 290 | errx(1, "Proxy auth response too long"); |
291 | r = strlen(buf); | 291 | r = strlen(buf); |
292 | if ((cnt = atomicio(vwrite, proxyfd, buf, r)) != r) | 292 | if ((cnt = atomicio(vwrite, proxyfd, buf, r)) != r) |
293 | err(1, "write failed (%d/%d)", cnt, r); | 293 | err(1, "write failed (%zu/%d)", cnt, r); |
294 | } | 294 | } |
295 | 295 | ||
296 | /* Terminate headers */ | 296 | /* Terminate headers */ |