summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2010-02-09 12:58:25 -0500
committerNick Mathewson <nickm@torproject.org>2010-02-09 12:58:25 -0500
commita6a1b8b815fd78845b44ff212c01263151fd2a10 (patch)
treeee2aaf6f0320da7ef8830450b469a6e0273544a9
parenta4065cd832dcbbe034dac1f42db7bdd315a7d734 (diff)
parenta168cd2a54355c77a72e6553e5e4c5dc844fca50 (diff)
downloadtor-a6a1b8b815fd78845b44ff212c01263151fd2a10.tar.gz
tor-a6a1b8b815fd78845b44ff212c01263151fd2a10.zip
Merge remote branch 'origin/maint-0.2.1'
-rw-r--r--ChangeLog3
-rw-r--r--src/or/config.c8
2 files changed, 6 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 476c217e4e..df0f3ef068 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -66,6 +66,9 @@ Changes in version 0.2.1.23 - 2010-0?-??
on, detect the OpenSSL version at run-time, not compile time. We
need to do this because Apple doesn't update its dev-tools headers
when it updates its libraries in a security patch.
+ - Refactor resolve_my_address() a little, to not use gethostbyname()
+ anymore. Fixes bug 1244; bugfix on 0.0.2pre25. Reported by Mike
+ Mestnik.
o Minor features:
- Avoid a mad rush at the beginning of each month when each client
diff --git a/src/or/config.c b/src/or/config.c
index b8356e2fc0..8421bfaa2d 100644
--- a/src/or/config.c
+++ b/src/or/config.c
@@ -2193,7 +2193,7 @@ resolve_my_address(int warn_severity, or_options_t *options,
uint32_t *addr_out, char **hostname_out)
{
struct in_addr in;
- struct hostent *rent;
+ uint32_t addr;
char hostname[256];
int explicit_ip=1;
int explicit_hostname=1;
@@ -2223,8 +2223,7 @@ resolve_my_address(int warn_severity, or_options_t *options,
if (tor_inet_aton(hostname, &in) == 0) {
/* then we have to resolve it */
explicit_ip = 0;
- rent = (struct hostent *)gethostbyname(hostname);
- if (!rent) {
+ if(!tor_lookup_hostname(hostname, &addr)) {
uint32_t interface_ip;
if (explicit_hostname) {
@@ -2247,8 +2246,7 @@ resolve_my_address(int warn_severity, or_options_t *options,
"local interface. Using that.", tmpbuf);
strlcpy(hostname, "<guessed from interfaces>", sizeof(hostname));
} else {
- tor_assert(rent->h_length == 4);
- memcpy(&in.s_addr, rent->h_addr, rent->h_length);
+ in.s_addr = htonl(addr);
if (!explicit_hostname &&
is_internal_IP(ntohl(in.s_addr), 0)) {