aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2013-03-15 12:11:38 -0400
committerNick Mathewson <nickm@torproject.org>2013-03-15 12:11:38 -0400
commite4d2177d31225f5884dd94038b457dfd9954b11b (patch)
tree4cae5e142c4f0d9c2588d168d665146f021540aa
parent18da1e0cf268bb56adc1a45fa4877e6a1bd2b470 (diff)
downloadtor-e4d2177d31225f5884dd94038b457dfd9954b11b.tar
tor-e4d2177d31225f5884dd94038b457dfd9954b11b.tar.gz
Fix some basic socket issues with tor-fw-helper-natpmp on windows
This isn't going to be the last of these issues, but we might as well take the fixes as we find them. Patch from Gisle Vanem, fixes bug 7280.
-rw-r--r--changes/bug72804
-rw-r--r--src/tools/tor-fw-helper/tor-fw-helper-natpmp.c14
2 files changed, 13 insertions, 5 deletions
diff --git a/changes/bug7280 b/changes/bug7280
new file mode 100644
index 000000000..ef5d36a80
--- /dev/null
+++ b/changes/bug7280
@@ -0,0 +1,4 @@
+ o Minor bugfixes:
+ - Fix some bugs in tor-fw-helper-natpmp when trying to build and
+ run it on Windows. More bugs likely remain. Patch from Gisle Vanem.
+ Fixes bug 7280; bugfix on 0.2.3.1-alpha.
diff --git a/src/tools/tor-fw-helper/tor-fw-helper-natpmp.c b/src/tools/tor-fw-helper/tor-fw-helper-natpmp.c
index e288a1ecf..41eb9dcb7 100644
--- a/src/tools/tor-fw-helper/tor-fw-helper-natpmp.c
+++ b/src/tools/tor-fw-helper/tor-fw-helper-natpmp.c
@@ -93,16 +93,20 @@ wait_until_fd_readable(tor_socket_t fd, struct timeval *timeout)
{
int r;
fd_set fds;
+
+#ifndef WIN32
if (fd >= FD_SETSIZE) {
fprintf(stderr, "E: NAT-PMP FD_SETSIZE error %d\n", fd);
return -1;
}
+#endif
+
FD_ZERO(&fds);
FD_SET(fd, &fds);
r = select(fd+1, &fds, NULL, NULL, timeout);
if (r == -1) {
fprintf(stderr, "V: select failed in wait_until_fd_readable: %s\n",
- strerror(errno));
+ tor_socket_strerror(tor_socket_errno(fd)));
return -1;
}
/* XXXX we should really check to see whether fd was readable, or we timed
@@ -140,12 +144,12 @@ tor_natpmp_add_tcp_mapping(uint16_t internal_port, uint16_t external_port,
if (is_verbose)
fprintf(stderr, "V: attempting to readnatpmpreponseorretry...\n");
r = readnatpmpresponseorretry(&(state->natpmp), &(state->response));
- sav_errno = errno;
+ sav_errno = tor_socket_errno(state->natpmp.s);
if (r<0 && r!=NATPMP_TRYAGAIN) {
fprintf(stderr, "E: readnatpmpresponseorretry failed %d\n", r);
fprintf(stderr, "E: errno=%d '%s'\n", sav_errno,
- strerror(sav_errno));
+ tor_socket_strerror(sav_errno));
}
} while (r == NATPMP_TRYAGAIN);
@@ -198,7 +202,7 @@ tor_natpmp_fetch_public_ip(tor_fw_options_t *tor_fw_options,
if (tor_fw_options->verbose)
fprintf(stderr, "V: NAT-PMP attempting to read reponse...\n");
r = readnatpmpresponseorretry(&(state->natpmp), &(state->response));
- sav_errno = errno;
+ sav_errno = tor_socket_errno(state->natpmp.s);
if (tor_fw_options->verbose)
fprintf(stderr, "V: NAT-PMP readnatpmpresponseorretry returned"
@@ -208,7 +212,7 @@ tor_natpmp_fetch_public_ip(tor_fw_options_t *tor_fw_options,
fprintf(stderr, "E: NAT-PMP readnatpmpresponseorretry failed %d\n",
r);
fprintf(stderr, "E: NAT-PMP errno=%d '%s'\n", sav_errno,
- strerror(sav_errno));
+ tor_socket_strerror(sav_errno));
}
} while (r == NATPMP_TRYAGAIN );