[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [tor/master] Rename sandbox_getaddrinfo() et. al.
commit 439b528f25e29b572a7bd04bc1d5fcaee68f5796
Author: rl1987 <rl1987@xxxxxxxxxxxxxxxx>
Date: Tue Jul 3 14:27:57 2018 +0300
Rename sandbox_getaddrinfo() et. al.
---
changes/bug26525 | 4 ++++
src/lib/net/address.c | 4 ++--
src/lib/net/resolve.c | 18 +++++++++---------
src/lib/net/resolve.h | 21 +++++++++------------
src/lib/sandbox/sandbox.c | 2 +-
src/or/main.c | 4 ++--
6 files changed, 27 insertions(+), 26 deletions(-)
diff --git a/changes/bug26525 b/changes/bug26525
new file mode 100644
index 000000000..27862eee9
--- /dev/null
+++ b/changes/bug26525
@@ -0,0 +1,4 @@
+ o Minor bugfixes (code quality):
+ - Rename sandbox_getaddrinfo() and other functions to no longer
+ misleadingly suggest that they are sandbox-only. Fixes bug
+ 26525; bugfix on 0.2.7.1-alpha.
diff --git a/src/lib/net/address.c b/src/lib/net/address.c
index 10e38871e..f3eddca7b 100644
--- a/src/lib/net/address.c
+++ b/src/lib/net/address.c
@@ -277,7 +277,7 @@ tor_addr_lookup,(const char *name, uint16_t family, tor_addr_t *addr))
memset(&hints, 0, sizeof(hints));
hints.ai_family = family;
hints.ai_socktype = SOCK_STREAM;
- err = sandbox_getaddrinfo(name, NULL, &hints, &res);
+ err = tor_getaddrinfo(name, NULL, &hints, &res);
/* The check for 'res' here shouldn't be necessary, but it makes static
* analysis tools happy. */
if (!err && res) {
@@ -306,7 +306,7 @@ tor_addr_lookup,(const char *name, uint16_t family, tor_addr_t *addr))
&((struct sockaddr_in6*)best->ai_addr)->sin6_addr);
result = 0;
}
- sandbox_freeaddrinfo(res);
+ tor_freeaddrinfo(res);
return result;
}
return (err == EAI_AGAIN) ? 1 : -1;
diff --git a/src/lib/net/resolve.c b/src/lib/net/resolve.c
index fefd5cceb..cbe368ccf 100644
--- a/src/lib/net/resolve.c
+++ b/src/lib/net/resolve.c
@@ -121,16 +121,16 @@ sandbox_disable_getaddrinfo_cache(void)
}
void
-sandbox_freeaddrinfo(struct addrinfo *ai)
+tor_freeaddrinfo(struct addrinfo *ai)
{
if (sandbox_getaddrinfo_cache_disabled)
freeaddrinfo(ai);
}
int
-sandbox_getaddrinfo(const char *name, const char *servname,
- const struct addrinfo *hints,
- struct addrinfo **res)
+tor_getaddrinfo(const char *name, const char *servname,
+ const struct addrinfo *hints,
+ struct addrinfo **res)
{
int err;
struct cached_getaddrinfo_item_t search, *item;
@@ -191,7 +191,7 @@ sandbox_getaddrinfo(const char *name, const char *servname,
}
int
-sandbox_add_addrinfo(const char *name)
+tor_add_addrinfo(const char *name)
{
struct addrinfo *res;
struct addrinfo hints;
@@ -204,16 +204,16 @@ sandbox_add_addrinfo(const char *name)
hints.ai_family = families[i];
res = NULL;
- (void) sandbox_getaddrinfo(name, NULL, &hints, &res);
+ (void) tor_getaddrinfo(name, NULL, &hints, &res);
if (res)
- sandbox_freeaddrinfo(res);
+ tor_freeaddrinfo(res);
}
return 0;
}
void
-sandbox_free_getaddrinfo_cache(void)
+tor_free_getaddrinfo_cache(void)
{
cached_getaddrinfo_item_t **next, **item, *this;
@@ -229,7 +229,7 @@ sandbox_free_getaddrinfo_cache(void)
}
void
-sandbox_make_getaddrinfo_cache_active(void)
+tor_make_getaddrinfo_cache_active(void)
{
sandbox_getaddrinfo_is_active = 1;
}
diff --git a/src/lib/net/resolve.h b/src/lib/net/resolve.h
index a225be87f..f2280ae7e 100644
--- a/src/lib/net/resolve.h
+++ b/src/lib/net/resolve.h
@@ -22,27 +22,24 @@ MOCK_DECL(int,tor_lookup_hostname,(const char *name, uint32_t *addr));
struct addrinfo;
#ifdef USE_SANDBOX_GETADDRINFO
/** Pre-calls getaddrinfo in order to pre-record result. */
-int sandbox_add_addrinfo(const char *addr);
+int tor_add_addrinfo(const char *addr);
-// XXXX rename these. They are named as though they were sandbox-only,
-// XXXX but in fact they're the only allowed entry point to getaddrinfo.
-// XXXX They don't invoke the sandbox code; they only have an internal cache.
struct addrinfo;
/** Replacement for getaddrinfo(), using pre-recorded results. */
-int sandbox_getaddrinfo(const char *name, const char *servname,
+int tor_getaddrinfo(const char *name, const char *servname,
const struct addrinfo *hints,
struct addrinfo **res);
-void sandbox_freeaddrinfo(struct addrinfo *addrinfo);
-void sandbox_free_getaddrinfo_cache(void);
-void sandbox_make_getaddrinfo_cache_active(void);
+void tor_freeaddrinfo(struct addrinfo *addrinfo);
+void tor_free_getaddrinfo_cache(void);
+void tor_make_getaddrinfo_cache_active(void);
#else /* !(defined(USE_SANDBOX_GETADDRINFO)) */
-#define sandbox_getaddrinfo(name, servname, hints, res) \
+#define tor_getaddrinfo(name, servname, hints, res) \
getaddrinfo((name),(servname), (hints),(res))
-#define sandbox_add_addrinfo(name) \
+#define tor_add_addrinfo(name) \
((void)(name))
-#define sandbox_freeaddrinfo(addrinfo) \
+#define tor_freeaddrinfo(addrinfo) \
freeaddrinfo((addrinfo))
-#define sandbox_free_getaddrinfo_cache()
+#define tor_free_getaddrinfo_cache()
#endif /* defined(USE_SANDBOX_GETADDRINFO) */
void sandbox_disable_getaddrinfo_cache(void);
diff --git a/src/lib/sandbox/sandbox.c b/src/lib/sandbox/sandbox.c
index e49cbd863..25dd6d1c2 100644
--- a/src/lib/sandbox/sandbox.c
+++ b/src/lib/sandbox/sandbox.c
@@ -1552,7 +1552,7 @@ install_syscall_filter(sandbox_cfg_t* cfg)
// marking the sandbox as active
sandbox_active = 1;
- sandbox_make_getaddrinfo_cache_active();
+ tor_make_getaddrinfo_cache_active();
end:
seccomp_release(ctx);
diff --git a/src/or/main.c b/src/or/main.c
index 81a8cfbee..d24f5a7ff 100644
--- a/src/or/main.c
+++ b/src/or/main.c
@@ -3668,7 +3668,7 @@ tor_free_all(int postfork)
routerparse_free_all();
ext_orport_free_all();
control_free_all();
- sandbox_free_getaddrinfo_cache();
+ tor_free_getaddrinfo_cache();
protover_free_all();
bridges_free_all();
consdiffmgr_free_all();
@@ -3890,7 +3890,7 @@ init_addrinfo(void)
// host name to sandbox
gethostname(hname, sizeof(hname));
- sandbox_add_addrinfo(hname);
+ tor_add_addrinfo(hname);
}
static sandbox_cfg_t*
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits