]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Fix 64-bit return issue in parse_log_domain()
authorNick Mathewson <nickm@torproject.org>
Mon, 19 Aug 2019 17:59:57 +0000 (13:59 -0400)
committerNick Mathewson <nickm@torproject.org>
Mon, 19 Aug 2019 17:59:57 +0000 (13:59 -0400)
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 [new file with mode: 0644]
src/lib/log/log.c

diff --git a/changes/ticket31451 b/changes/ticket31451
new file mode 100644 (file)
index 0000000..773d665
--- /dev/null
@@ -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.
index d95bf1ff6ea42bc9d27cb2b4fc3c9fba5f761e4f..56f016eae41305e6ffa5284ebc343978b61b95b7 100644 (file)
@@ -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;
 }