summaryrefslogtreecommitdiff
path: root/evdns.c
diff options
context:
space:
mode:
authorVilmos Nebehaj <v.nebehaj@gmail.com>2014-03-21 14:38:11 +0100
committerVilmos Nebehaj <v.nebehaj@gmail.com>2014-03-21 14:38:11 +0100
commitd0dc861b881e129ab9afb26cfe5df99187eeb53d (patch)
tree7c68b182ae18d3db5dbbe0703177b5c205bb0782 /evdns.c
parenta0b247cdc0cfff55c7966fc99ce62bd6cfe2c309 (diff)
downloadlibevent-d0dc861b881e129ab9afb26cfe5df99187eeb53d.tar.gz
Don't truncate hosts file path on Windows.
Since evutil_snprintf() (actually evutil_vsnprintf() called by it) will make sure the buffer is null-terminated by placing a null byte at len_out - 1, we need to pass the full length of the buffer; otherwise the path will end in "\\host" instead of "\\hosts".
Diffstat (limited to 'evdns.c')
-rw-r--r--evdns.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/evdns.c b/evdns.c
index a143074d..a1d8c95a 100644
--- a/evdns.c
+++ b/evdns.c
@@ -3555,8 +3555,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