]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Have LOG_PROTOCOL_WARN call its own function
authorNick Mathewson <nickm@torproject.org>
Mon, 23 Oct 2017 16:20:58 +0000 (12:20 -0400)
committerNick Mathewson <nickm@torproject.org>
Mon, 23 Oct 2017 16:22:26 +0000 (12:22 -0400)
Also, make the function that implements LOG_PROTOCOL_WARN use a
cached value of the desired loglevel, rather than calling
get_options().

changes/bug23952 [new file with mode: 0644]
src/or/config.c
src/or/config.h
src/or/or.h

diff --git a/changes/bug23952 b/changes/bug23952
new file mode 100644 (file)
index 0000000..ab1462e
--- /dev/null
@@ -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.
index 94c4d790acce0aa61ee52acd4320b40c3ac310ca..a2353b94db347d7a84a0162e57b9dbb32755dee0 100644 (file)
@@ -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;
 
index f69a3c483f92ab88d3e0e7b574ef62e5b09c2e9f..af945f16be2f64c64036a8d2076c6867891f5ba6 100644 (file)
@@ -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,
index 5bd07ba6a37b336516dd61c21f03f7d8c414c324..8c1ef478ed7a9607642eb37c31f9eb5fef040f05 100644 (file)
@@ -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_;