aboutsummaryrefslogtreecommitdiff
path: root/src/or/eventdns.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2012-05-17 10:08:48 -0400
committerNick Mathewson <nickm@torproject.org>2012-06-07 11:09:38 -0400
commit1e5683b167a612bf76d4ae9ba508027e0d473e52 (patch)
tree5bd336b4f17411122c8ddb152324f8c2922d4d6e /src/or/eventdns.c
parent99618a9641d02b7b99a79c71517203bb70043515 (diff)
downloadtor-1e5683b167a612bf76d4ae9ba508027e0d473e52.tar.gz
tor-1e5683b167a612bf76d4ae9ba508027e0d473e52.zip
Be more careful calling wcstombs
The function is not guaranteed to NUL-terminate its output. It *is*, however, guaranteed not to generate more than two bytes per multibyte character (plus terminating nul), so the general approach I'm taking is to try to allocate enough space, AND to manually add a NUL at the end of each buffer just in case I screwed up the "enough space" thing. Fixes bug 5909.
Diffstat (limited to 'src/or/eventdns.c')
-rw-r--r--src/or/eventdns.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/or/eventdns.c b/src/or/eventdns.c
index 61a28361ab..768693aba6 100644
--- a/src/or/eventdns.c
+++ b/src/or/eventdns.c
@@ -3213,7 +3213,7 @@ static int
config_nameserver_from_reg_key(HKEY key, const TCHAR *subkey)
{
char *buf;
- char ansibuf[MAX_PATH] = {0};
+ char ansibuf[MAX_PATH] = {0};
DWORD bufsz = 0, type = 0;
int status = 0;
@@ -3226,6 +3226,7 @@ config_nameserver_from_reg_key(HKEY key, const TCHAR *subkey)
if (RegQueryValueEx(key, subkey, 0, &type, (LPBYTE)buf, &bufsz)
== ERROR_SUCCESS && bufsz > 1) {
wcstombs(ansibuf,(wchar_t*)buf,MAX_PATH);/*XXXX UNICODE */
+ abuf[MAX_PATH-1] = '\0';
status = evdns_nameserver_ip_add_line(ansibuf);
}