[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor/release-0.3.2] Have LOG_PROTOCOL_WARN call its own function



commit 48ee85e0c6c83c31693bc58ca4e8e91c8031421d
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date:   Mon Oct 23 12:20:58 2017 -0400

    Have LOG_PROTOCOL_WARN call its own function
    
    Also, make the function that implements LOG_PROTOCOL_WARN use a
    cached value of the desired loglevel, rather than calling
    get_options().
---
 changes/bug23952 |  4 ++++
 src/or/config.c  | 22 ++++++++++++++++++++++
 src/or/config.h  |  1 +
 src/or/or.h      |  4 ++--
 4 files changed, 29 insertions(+), 2 deletions(-)

diff --git a/changes/bug23952 b/changes/bug23952
new file mode 100644
index 000000000..ab1462e52
--- /dev/null
+++ b/changes/bug23952
@@ -0,0 +1,4 @@
+  o Minor bugfixes (relay):
+    - Avoid a BUG warning when receiving a dubious CREATE cell while
+      an option transition is in progress. Fixes bug 23952; bugfix on
+      0.3.2.1-alpha.
diff --git a/src/or/config.c b/src/or/config.c
index 94c4d790a..a2353b94d 100644
--- a/src/or/config.c
+++ b/src/or/config.c
@@ -1030,6 +1030,23 @@ escaped_safe_str(const char *address)
     return escaped(address);
 }
 
+/**
+ * The severity level that should be used for warnings of severity
+ * LOG_PROTOCOL_WARN.
+ *
+ * We keep this outside the options, in case somebody needs to use
+ * LOG_PROTOCOL_WARN while an option transition is happening.
+ */
+static int protocol_warning_severity_level = LOG_WARN;
+
+/** Return the severity level that should be used for warnings of severity
+ * LOG_PROTOCOL_WARN. */
+int
+get_protocol_warning_severity_level(void)
+{
+  return protocol_warning_severity_level;
+}
+
 /** List of default directory authorities */
 
 static const char *default_authorities[] = {
@@ -1667,6 +1684,11 @@ options_act(const or_options_t *old_options)
       return -1;
   }
 
+  if (options->ProtocolWarnings)
+    protocol_warning_severity_level = LOG_WARN;
+  else
+    protocol_warning_severity_level = LOG_INFO;
+
   if (consider_adding_dir_servers(options, old_options) < 0)
     return -1;
 
diff --git a/src/or/config.h b/src/or/config.h
index f69a3c483..af945f16b 100644
--- a/src/or/config.h
+++ b/src/or/config.h
@@ -31,6 +31,7 @@ const char *safe_str_client(const char *address);
 const char *safe_str(const char *address);
 const char *escaped_safe_str_client(const char *address);
 const char *escaped_safe_str(const char *address);
+int get_protocol_warning_severity_level(void);
 const char *get_version(void);
 const char *get_short_version(void);
 setopt_err_t options_trial_assign(config_line_t *list, unsigned flags,
diff --git a/src/or/or.h b/src/or/or.h
index 5bd07ba6a..8c1ef478e 100644
--- a/src/or/or.h
+++ b/src/or/or.h
@@ -4079,8 +4079,6 @@ typedef struct {
   int Sandbox; /**< Boolean: should sandboxing be enabled? */
   int SafeSocks; /**< Boolean: should we outright refuse application
                   * connections that use socks4 or socks5-with-local-dns? */
-#define LOG_PROTOCOL_WARN (get_options()->ProtocolWarnings ? \
-                           LOG_WARN : LOG_INFO)
   int ProtocolWarnings; /**< Boolean: when other parties screw up the Tor
                          * protocol, is it a warn or an info in our logs? */
   int TestSocks; /**< Boolean: when we get a socks connection, do we loudly
@@ -4627,6 +4625,8 @@ typedef struct {
   smartlist_t *SchedulerTypes_;
 } or_options_t;
 
+#define LOG_PROTOCOL_WARN (get_protocol_warning_severity_level())
+
 /** Persistent state for an onion router, as saved to disk. */
 typedef struct {
   uint32_t magic_;



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits