]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Add a compile-time assertion to prevent a recurrence of 31080.
authorNick Mathewson <nickm@torproject.org>
Mon, 8 Jul 2019 17:41:35 +0000 (13:41 -0400)
committerNick Mathewson <nickm@torproject.org>
Mon, 8 Jul 2019 17:41:35 +0000 (13:41 -0400)
src/lib/log/log.c
src/lib/log/log.h

index c68f335da6c68e81939eecd412d4bfc4331bbaf5..756eb2a9732d79e21a8009bc4dbec3165cfbee4d 100644 (file)
@@ -1275,6 +1275,8 @@ static const char *domain_list[] = {
 
 CTASSERT(ARRAY_LENGTH(domain_list) == N_LOGGING_DOMAINS + 1);
 
+CTASSERT((UINT64_C(1)<<(N_LOGGING_DOMAINS-1)) < LOWEST_RESERVED_LD_FLAG_);
+
 /** Return a bitmask for the log domain for which <b>domain</b> is the name,
  * or 0 if there is no such name. */
 static log_domain_mask_t
index 801bafa968ee8e59312c360c3ba9efb2d3d5731b..88e4ad8d618a1fa59f6fadf5f4d86264434d53f2 100644 (file)
 #define LD_MESG      (UINT64_C(1)<<29)
 #define N_LOGGING_DOMAINS 30
 
+/** First bit that is reserved in log_domain_mask_t for non-domain flags. */
+#define LOWEST_RESERVED_LD_FLAG_ (UINT64_C(1)<<61)
 #ifdef TOR_UNIT_TESTS
 /** This log message should not be intercepted by mock_saving_logv */
 #define LD_NO_MOCK (UINT64_C(1)<<61)