[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [tor/master] Add a string representation for LD_SCHED, and a extra sanity check.
commit b330bdec8e628d34641a5e6942fa4d1a5357639a
Author: Yawning Angel <yawning@xxxxxxxxxxxxxxx>
Date: Thu Feb 5 15:46:27 2015 +0000
Add a string representation for LD_SCHED, and a extra sanity check.
This both fixes the problem, and ensures that forgetting to update
domain_list in the future will trigger the bug codepath instead of
a NULL pointer deref.
---
changes/bug14740 | 5 +++++
src/common/log.c | 6 ++++--
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/changes/bug14740 b/changes/bug14740
new file mode 100644
index 0000000..5cac620
--- /dev/null
+++ b/changes/bug14740
@@ -0,0 +1,5 @@
+ o Minor bugfixes:
+ - Avoid crashing when there are more log domains than entries in
+ domain_list. Bugfix on 0.2.3.1-alpha.
+ - Add a string representation for LD_SCHED. Fixes bug 14740;
+ bugfix on 0.2.6.1-alpha.
diff --git a/src/common/log.c b/src/common/log.c
index 2e7c711..b533814 100644
--- a/src/common/log.c
+++ b/src/common/log.c
@@ -1215,7 +1215,8 @@ log_level_to_string(int level)
static const char *domain_list[] = {
"GENERAL", "CRYPTO", "NET", "CONFIG", "FS", "PROTOCOL", "MM",
"HTTP", "APP", "CONTROL", "CIRC", "REND", "BUG", "DIR", "DIRSERV",
- "OR", "EDGE", "ACCT", "HIST", "HANDSHAKE", "HEARTBEAT", "CHANNEL", NULL
+ "OR", "EDGE", "ACCT", "HIST", "HANDSHAKE", "HEARTBEAT", "CHANNEL",
+ "SCHED", NULL
};
/** Return a bitmask for the log domain for which <b>domain</b> is the name,
@@ -1245,7 +1246,8 @@ domain_to_string(log_domain_mask_t domain, char *buf, size_t buflen)
const char *d;
int bit = tor_log2(domain);
size_t n;
- if (bit >= N_LOGGING_DOMAINS) {
+ if ((unsigned)bit >= sizeof(domain_list)/sizeof(*domain_list) - 1 ||
+ bit >= N_LOGGING_DOMAINS) {
tor_snprintf(buf, buflen, "<BUG:Unknown domain %lx>", (long)domain);
return buf+strlen(buf);
}
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits