diff options
author | Nick Mathewson <nickm@freehaven.net> | 2014-09-18 11:41:18 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@freehaven.net> | 2014-09-18 11:41:18 -0400 |
commit | c8c7fa3a163bf968a5057349cb5e8aeee7604cd0 (patch) | |
tree | 59aa498a5fe21764583369d54c6ffd52e37567e4 | |
parent | 3cc0eace2e3fb72310af7d7f8c0f8ffac6cb1635 (diff) | |
parent | d0dc861b881e129ab9afb26cfe5df99187eeb53d (diff) | |
download | libevent-c8c7fa3a163bf968a5057349cb5e8aeee7604cd0.tar.gz |
Merge pull request #119 from ldx/winhosts
Fix hosts file use on Windows.
-rw-r--r-- | evdns.c | 15 |
1 files changed, 8 insertions, 7 deletions
@@ -3556,8 +3556,8 @@ evdns_get_default_hosts_filename(void) if (! SHGetSpecialFolderPathA(NULL, path, CSIDL_SYSTEM, 0)) return NULL; - len_out = strlen(path)+strlen(hostfile); - path_out = mm_malloc(len_out+1); + len_out = strlen(path)+strlen(hostfile)+1; + path_out = mm_malloc(len_out); evutil_snprintf(path_out, len_out, "%s%s", path, hostfile); return path_out; #else @@ -3827,17 +3827,18 @@ evdns_base_config_windows_nameservers(struct evdns_base *base) if (base == NULL) return -1; EVDNS_LOCK(base); + fname = evdns_get_default_hosts_filename(); + log(EVDNS_LOG_DEBUG, "Loading hosts entries from %s", fname); + evdns_base_load_hosts(base, fname); + if (fname) + mm_free(fname); + if (load_nameservers_with_getnetworkparams(base) == 0) { EVDNS_UNLOCK(base); return 0; } r = load_nameservers_from_registry(base); - fname = evdns_get_default_hosts_filename(); - evdns_base_load_hosts(base, fname); - if (fname) - mm_free(fname); - EVDNS_UNLOCK(base); return r; } |