mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-24 12:23:32 +01:00
log: When initialising log domain masks, only set known log domains
And add a runtime test that checks for unknown domains and flags. Fixes bug 31854; bugfix on 0.2.1.1-alpha.
This commit is contained in:
parent
25c5322dfe
commit
db329522ef
3
changes/bug31854
Normal file
3
changes/bug31854
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
o Minor bugfixes (logging):
|
||||||
|
- When initialising log domain masks, only set known log domains.
|
||||||
|
Fixes bug 31854; bugfix on 0.2.1.1-alpha.
|
@ -628,6 +628,10 @@ void
|
|||||||
tor_log(int severity, log_domain_mask_t domain, const char *format, ...)
|
tor_log(int severity, log_domain_mask_t domain, const char *format, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
||||||
|
/* check that domain is composed of known domains and flags */
|
||||||
|
raw_assert((domain & (LD_ALL_DOMAINS|LD_ALL_FLAGS)) == domain);
|
||||||
|
|
||||||
if (severity > log_global_min_severity_)
|
if (severity > log_global_min_severity_)
|
||||||
return;
|
return;
|
||||||
va_start(ap,format);
|
va_start(ap,format);
|
||||||
@ -927,7 +931,7 @@ set_log_severity_config(int loglevelMin, int loglevelMax,
|
|||||||
raw_assert(loglevelMax >= LOG_ERR && loglevelMax <= LOG_DEBUG);
|
raw_assert(loglevelMax >= LOG_ERR && loglevelMax <= LOG_DEBUG);
|
||||||
memset(severity_out, 0, sizeof(log_severity_list_t));
|
memset(severity_out, 0, sizeof(log_severity_list_t));
|
||||||
for (i = loglevelMin; i >= loglevelMax; --i) {
|
for (i = loglevelMin; i >= loglevelMax; --i) {
|
||||||
severity_out->masks[SEVERITY_MASK_IDX(i)] = ~0u;
|
severity_out->masks[SEVERITY_MASK_IDX(i)] = LD_ALL_DOMAINS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1421,7 +1425,7 @@ parse_log_severity_config(const char **cfg_ptr,
|
|||||||
const char *dash, *space;
|
const char *dash, *space;
|
||||||
char *sev_lo, *sev_hi;
|
char *sev_lo, *sev_hi;
|
||||||
int low, high, i;
|
int low, high, i;
|
||||||
log_domain_mask_t domains = ~0u;
|
log_domain_mask_t domains = LD_ALL_DOMAINS;
|
||||||
|
|
||||||
if (*cfg == '[') {
|
if (*cfg == '[') {
|
||||||
int err = 0;
|
int err = 0;
|
||||||
@ -1439,7 +1443,7 @@ parse_log_severity_config(const char **cfg_ptr,
|
|||||||
tor_free(domains_str);
|
tor_free(domains_str);
|
||||||
SMARTLIST_FOREACH_BEGIN(domains_list, const char *, domain) {
|
SMARTLIST_FOREACH_BEGIN(domains_list, const char *, domain) {
|
||||||
if (!strcmp(domain, "*")) {
|
if (!strcmp(domain, "*")) {
|
||||||
domains = ~0u;
|
domains = LD_ALL_DOMAINS;
|
||||||
} else {
|
} else {
|
||||||
log_domain_mask_t d;
|
log_domain_mask_t d;
|
||||||
int negate=0;
|
int negate=0;
|
||||||
@ -1535,7 +1539,7 @@ switch_logs_debug(void)
|
|||||||
LOCK_LOGS();
|
LOCK_LOGS();
|
||||||
for (lf = logfiles; lf; lf=lf->next) {
|
for (lf = logfiles; lf; lf=lf->next) {
|
||||||
for (i = LOG_DEBUG; i >= LOG_ERR; --i)
|
for (i = LOG_DEBUG; i >= LOG_ERR; --i)
|
||||||
lf->severities->masks[SEVERITY_MASK_IDX(i)] = ~0u;
|
lf->severities->masks[SEVERITY_MASK_IDX(i)] = LD_ALL_DOMAINS;
|
||||||
}
|
}
|
||||||
log_global_min_severity_ = get_min_log_level();
|
log_global_min_severity_ = get_min_log_level();
|
||||||
UNLOCK_LOGS();
|
UNLOCK_LOGS();
|
||||||
|
@ -54,9 +54,9 @@ setup_log_callback(void)
|
|||||||
{
|
{
|
||||||
log_severity_list_t lst;
|
log_severity_list_t lst;
|
||||||
memset(&lst, 0, sizeof(lst));
|
memset(&lst, 0, sizeof(lst));
|
||||||
lst.masks[SEVERITY_MASK_IDX(LOG_ERR)] = ~0;
|
lst.masks[SEVERITY_MASK_IDX(LOG_ERR)] = LD_ALL_DOMAINS;
|
||||||
lst.masks[SEVERITY_MASK_IDX(LOG_WARN)] = ~0;
|
lst.masks[SEVERITY_MASK_IDX(LOG_WARN)] = LD_ALL_DOMAINS;
|
||||||
lst.masks[SEVERITY_MASK_IDX(LOG_NOTICE)] = ~0;
|
lst.masks[SEVERITY_MASK_IDX(LOG_NOTICE)] = LD_ALL_DOMAINS;
|
||||||
add_callback_log(&lst, log_cback);
|
add_callback_log(&lst, log_cback);
|
||||||
mark_logs_temp();
|
mark_logs_temp();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user