diff options
author | Stuart Henderson <sthen@cvs.openbsd.org> | 2014-01-15 02:25:35 +0000 |
---|---|---|
committer | Stuart Henderson <sthen@cvs.openbsd.org> | 2014-01-15 02:25:35 +0000 |
commit | 86ad9ac721f74e4b2cf6c02acf8fe218f7059609 (patch) | |
tree | 609d18b957dfe5ed721b4a5eea664afa5ac8efb2 | |
parent | c5e81ffd53a6a06c8de02b4e55ae66e7ae64850b (diff) |
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@.
-rw-r--r-- | lib/libc/asr/res_init.c | 7 |
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); |