aboutsummaryrefslogtreecommitdiffstats
path: root/socks.c
diff options
context:
space:
mode:
authorXin LI <delphij@FreeBSD.org>2011-05-11 18:57:17 +0000
committerXin LI <delphij@FreeBSD.org>2011-05-11 18:57:17 +0000
commitc98f06c929bb8c8a81b4254bebab2fb08a98b6ce (patch)
treee369e613d9739710b96ef90916dbaa1376d1c210 /socks.c
parentb46a1ee8f0756ffa8aff09939ad8c814b10b8931 (diff)
downloadsrc-c98f06c929bb8c8a81b4254bebab2fb08a98b6ce.tar.gz
src-c98f06c929bb8c8a81b4254bebab2fb08a98b6ce.zip
Import nc from OpenBSD 4.9.vendor/netcat/4.9
Notes
Notes: svn path=/vendor/netcat/dist/; revision=221785 svn path=/vendor/netcat/4.9/; revision=221786; tag=vendor/netcat/4.9
Diffstat (limited to 'socks.c')
-rw-r--r--socks.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/socks.c b/socks.c
index b38dff741e19..71108d543b38 100644
--- a/socks.c
+++ b/socks.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: socks.c,v 1.18 2010/04/20 07:26:35 nicm Exp $ */
+/* $OpenBSD: socks.c,v 1.19 2011/02/12 15:54:18 okan Exp $ */
/*
* Copyright (c) 1999 Niklas Hallqvist. All rights reserved.
@@ -222,11 +222,25 @@ socks_connect(const char *host, const char *port,
if (cnt != wlen)
err(1, "write failed (%zu/%zu)", cnt, wlen);
- cnt = atomicio(read, proxyfd, buf, 10);
- if (cnt != 10)
- err(1, "read failed (%zu/10)", cnt);
+ cnt = atomicio(read, proxyfd, buf, 4);
+ if (cnt != 4)
+ err(1, "read failed (%zu/4)", cnt);
if (buf[1] != 0)
errx(1, "connection failed, SOCKS error %d", buf[1]);
+ switch (buf[3]) {
+ case SOCKS_IPV4:
+ cnt = atomicio(read, proxyfd, buf + 4, 6);
+ if (cnt != 6)
+ err(1, "read failed (%d/6)", cnt);
+ break;
+ case SOCKS_IPV6:
+ cnt = atomicio(read, proxyfd, buf + 4, 18);
+ if (cnt != 18)
+ err(1, "read failed (%d/18)", cnt);
+ break;
+ default:
+ errx(1, "connection failed, unsupported address type");
+ }
} else if (socksv == 4) {
/* This will exit on lookup failure */
decode_addrport(host, port, (struct sockaddr *)&addr,