From: Andreas Schneider Date: Thu, 17 Dec 2015 07:46:33 +0000 (+0100) Subject: nwrap: Fix segfaults while reloading hosts file X-Git-Url: http://git.samba.org/?p=obnox%2Fsamba%2Fsamba-obnox.git;a=commitdiff_plain;h=da292b606230190e65f7ef17d23f8c7a65135ecb nwrap: Fix segfaults while reloading hosts file Signed-off-by: Andreas Schneider Reviewed-by: Michael Adam --- diff --git a/lib/nss_wrapper/nss_wrapper.c b/lib/nss_wrapper/nss_wrapper.c index f48b9cc7e8d..c4f1b33e496 100644 --- a/lib/nss_wrapper/nss_wrapper.c +++ b/lib/nss_wrapper/nss_wrapper.c @@ -2890,6 +2890,7 @@ static void nwrap_he_unload(struct nwrap_cache *nwrap) struct nwrap_entdata *ed; struct nwrap_entlist *el; size_t i; + int rc; nwrap_vector_foreach (ed, nwrap_he->entries, i) { @@ -2915,6 +2916,18 @@ static void nwrap_he_unload(struct nwrap_cache *nwrap) nwrap_he->num = 0; nwrap_he->idx = 0; + + /* + * If we unload the file, the pointers in the hash table point to + * invalid memory. So we need to destroy the hash table and recreate + * it. + */ + hdestroy(); + rc = hcreate(max_hostents); + if (rc == 0) { + NWRAP_LOG(NWRAP_LOG_ERROR, "Failed to initialize hash table"); + exit(-1); + } }