[tor/master] Fix 64-bit return issue in parse_log_domain()

commit 87a3c5b1109a65fdf9b436f1035126044d77e552 Author: Nick Mathewson <nickm@torproject.org> Date: Mon Aug 19 13:59:57 2019 -0400 Fix 64-bit return issue in parse_log_domain() If unsigned int is 32-bits long, then our old code would give a wrong result with any log domain whose mask was >= (1<<32). Fortunately, there are no such log domains right now: the domain mask is only 64 bits long to accommodate some flags. Found by coverity as CID 1452041. Fixes bug 31451; bugfix on 0.4.1.4-rc. --- changes/ticket31451 | 4 ++++ src/lib/log/log.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/changes/ticket31451 b/changes/ticket31451 new file mode 100644 index 000000000..773d66595 --- /dev/null +++ b/changes/ticket31451 @@ -0,0 +1,4 @@ + o Minor bugfixes (logging): + - Fix a code issue that would have broken our parsing of log + domains as soon as we had 33 of them. Fortunately, we still + only have 29. Fixes bug 31451; bugfix on 0.4.1.4-rc. diff --git a/src/lib/log/log.c b/src/lib/log/log.c index d95bf1ff6..56f016eae 100644 --- a/src/lib/log/log.c +++ b/src/lib/log/log.c @@ -1285,7 +1285,7 @@ parse_log_domain(const char *domain) int i; for (i=0; domain_list[i]; ++i) { if (!strcasecmp(domain, domain_list[i])) - return (1u<<i); + return (UINT64_C(1)<<i); } return 0; }
participants (1)
-
asn@torproject.org