Merge remote-tracking branch 'yawning/bug14740'

This commit is contained in:
Nick Mathewson 2015-02-05 10:59:44 -05:00
commit 377584abbd
2 changed files with 9 additions and 2 deletions

5
changes/bug14740 Normal file
View File

@ -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.

View File

@ -1215,7 +1215,8 @@ log_level_to_string(int level)
static const char *domain_list[] = { static const char *domain_list[] = {
"GENERAL", "CRYPTO", "NET", "CONFIG", "FS", "PROTOCOL", "MM", "GENERAL", "CRYPTO", "NET", "CONFIG", "FS", "PROTOCOL", "MM",
"HTTP", "APP", "CONTROL", "CIRC", "REND", "BUG", "DIR", "DIRSERV", "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, /** 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; const char *d;
int bit = tor_log2(domain); int bit = tor_log2(domain);
size_t n; 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); tor_snprintf(buf, buflen, "<BUG:Unknown domain %lx>", (long)domain);
return buf+strlen(buf); return buf+strlen(buf);
} }