summaryrefslogtreecommitdiffstats
path: root/lib/libc/asr/res_init.c
diff options
context:
space:
mode:
authorsthen <sthen@openbsd.org>2014-01-15 02:25:34 +0000
committersthen <sthen@openbsd.org>2014-01-15 02:25:34 +0000
commit38a63ed178c3f19f41ef0c3434b850a5cf50fd7e (patch)
tree23f0f908240b309a72b17982be35acacbf2cf313 /lib/libc/asr/res_init.c
parentSince we now show the installer output we want that new line back. (diff)
downloadwireguard-openbsd-38a63ed178c3f19f41ef0c3434b850a5cf50fd7e.tar.xz
wireguard-openbsd-38a63ed178c3f19f41ef0c3434b850a5cf50fd7e.zip
Initialise _res.nsaddr_list in res_init(), fixing some programs which depend
on bind resolver internals. Note, the list will not be updated if resolv.conf is changed while the program runs unless the caller resets the RES_INIT flag. Approach suggested by otto@, original diff from Kapetanakis Giannis, fix suggested by tedu@ and dug up again by Riccardo Mottola. Looks ok to eric@.
Diffstat (limited to 'lib/libc/asr/res_init.c')
-rw-r--r--lib/libc/asr/res_init.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/libc/asr/res_init.c b/lib/libc/asr/res_init.c
index c8958793b46..9fa0529baab 100644
--- a/lib/libc/asr/res_init.c
+++ b/lib/libc/asr/res_init.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: res_init.c,v 1.2 2013/05/27 17:31:01 eric Exp $ */
+/* $OpenBSD: res_init.c,v 1.3 2014/01/15 02:25:34 sthen Exp $ */
/*
* Copyright (c) 2012 Eric Faurot <eric@openbsd.org>
*
@@ -37,6 +37,7 @@ res_init(void)
{
_THREAD_PRIVATE_MUTEX(init);
struct asr_ctx *ac;
+ int i;
ac = asr_use_resolver(NULL);
@@ -55,6 +56,10 @@ res_init(void)
strlcpy(_res.lookups, ac->ac_db, sizeof(_res.lookups));
_res.nscount = ac->ac_nscount;
+ for (i = 0; i < ac->ac_nscount; i++) {
+ memcpy(&_res.nsaddr_list[i], ac->ac_ns[i],
+ ac->ac_ns[i]->sa_len);
+ }
_res.options |= RES_INIT;
}
_THREAD_PRIVATE_MUTEX_UNLOCK(init);