[tor-commits] [tor/maint-0.4.1] Add a compile-time assertion to prevent a recurrence of 31080.
dgoulet at torproject.org
dgoulet at torproject.org
Thu Jul 25 13:09:13 UTC 2019
commit 4512578e49b187075d4e8b4d07a0c921a15d5135
Author: Nick Mathewson <nickm at torproject.org>
Date: Mon Jul 8 13:41:35 2019 -0400
Add a compile-time assertion to prevent a recurrence of 31080.
---
src/lib/log/log.c | 2 ++
src/lib/log/log.h | 2 ++
2 files changed, 4 insertions(+)
diff --git a/src/lib/log/log.c b/src/lib/log/log.c
index c68f335da..756eb2a97 100644
--- a/src/lib/log/log.c
+++ b/src/lib/log/log.c
@@ -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
diff --git a/src/lib/log/log.h b/src/lib/log/log.h
index 801bafa96..88e4ad8d6 100644
--- a/src/lib/log/log.h
+++ b/src/lib/log/log.h
@@ -118,6 +118,8 @@
#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)
More information about the tor-commits
mailing list