diff options
author | Nick Mathewson <nickm@torproject.org> | 2014-09-29 13:02:50 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2014-09-29 13:02:50 -0400 |
commit | 2e607ff51931b35ee531fa60b83487b3f4f944a7 (patch) | |
tree | 005f66b245b8afadf2106dff94491610bfb81473 /src/common | |
parent | a0be2f1350bf4974a9655421c3b30ba87a7b2279 (diff) | |
parent | e1a25f0c3602e007872277ef9ab437cc97cfd47b (diff) | |
download | tor-2e607ff51931b35ee531fa60b83487b3f4f944a7.tar.gz tor-2e607ff51931b35ee531fa60b83487b3f4f944a7.zip |
Merge remote-tracking branch 'origin/maint-0.2.5'
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/sandbox.c | 21 | ||||
-rw-r--r-- | src/common/sandbox.h | 2 |
2 files changed, 23 insertions, 0 deletions
diff --git a/src/common/sandbox.c b/src/common/sandbox.c index c7e4dcdf55..36022c921c 100644 --- a/src/common/sandbox.c +++ b/src/common/sandbox.c @@ -1297,6 +1297,18 @@ HT_GENERATE2(getaddrinfo_cache, cached_getaddrinfo_item_t, node, cached_getaddrinfo_items_eq, 0.6, tor_reallocarray_, tor_free_) +/** If true, don't try to cache getaddrinfo results. */ +static int sandbox_getaddrinfo_cache_disabled = 0; + +/** Tell the sandbox layer not to try to cache getaddrinfo results. Used as in + * tor-resolve, when we have no intention of initializing crypto or of + * installing the sandbox.*/ +void +sandbox_disable_getaddrinfo_cache(void) +{ + sandbox_getaddrinfo_cache_disabled = 1; +} + int sandbox_getaddrinfo(const char *name, const char *servname, const struct addrinfo *hints, @@ -1305,6 +1317,10 @@ sandbox_getaddrinfo(const char *name, const char *servname, int err; struct cached_getaddrinfo_item_t search, *item; + if (sandbox_getaddrinfo_cache_disabled) { + return getaddrinfo(name, NULL, hints, res); + } + if (servname != NULL) { log_warn(LD_BUG, "called with non-NULL servname"); return EAI_NONAME; @@ -1718,5 +1734,10 @@ sandbox_is_active(void) { return 0; } + +void +sandbox_disable_getaddrinfo_cache(void) +{ +} #endif diff --git a/src/common/sandbox.h b/src/common/sandbox.h index 095d8d47f4..ddb2be5695 100644 --- a/src/common/sandbox.h +++ b/src/common/sandbox.h @@ -176,5 +176,7 @@ int sandbox_init(sandbox_cfg_t* cfg); /** Return true iff the sandbox is turned on. */ int sandbox_is_active(void); +void sandbox_disable_getaddrinfo_cache(void); + #endif /* SANDBOX_H_ */ |