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

[tor-commits] [tor/master] config, state: check magic in all callbacks.



commit 63f2a310cbeb5908a202ba17da7e66535c77c894
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date:   Fri Oct 25 08:09:05 2019 -0400

    config,state: check magic in all callbacks.
---
 src/app/config/config.c    | 11 +++++++++++
 src/app/config/statefile.c |  5 +++++
 2 files changed, 16 insertions(+)

diff --git a/src/app/config/config.c b/src/app/config/config.c
index b6927b8b7..f2db0e525 100644
--- a/src/app/config/config.c
+++ b/src/app/config/config.c
@@ -921,6 +921,10 @@ get_options_mgr(void)
   return options_mgr;
 }
 
+#define CHECK_OPTIONS_MAGIC(opt) STMT_BEGIN                      \
+    config_check_toplevel_magic(get_options_mgr(), (opt));       \
+  STMT_END
+
 /** Return the contents of our frontpage string, or NULL if not configured. */
 MOCK_IMPL(const char*,
 get_dirportfrontpage, (void))
@@ -1027,6 +1031,7 @@ static void
 options_clear_cb(const config_mgr_t *mgr, void *opts)
 {
   (void)mgr;
+  CHECK_OPTIONS_MAGIC(opts);
   or_options_t *options = opts;
 
   routerset_free(options->ExcludeExitNodesUnion_);
@@ -3467,6 +3472,9 @@ options_validate_single_onion(or_options_t *options, char **msg)
 static int
 options_validate_cb(const void *old_options_, void *options_, char **msg)
 {
+  if (old_options_)
+    CHECK_OPTIONS_MAGIC(old_options_);
+  CHECK_OPTIONS_MAGIC(options_);
   const or_options_t *old_options = old_options_;
   or_options_t *options = options_;
 
@@ -4821,6 +4829,9 @@ options_check_transition_cb(const void *old_,
                             const void *new_val_,
                             char **msg)
 {
+  CHECK_OPTIONS_MAGIC(old_);
+  CHECK_OPTIONS_MAGIC(new_val_);
+
   const or_options_t *old = old_;
   const or_options_t *new_val = new_val_;
 
diff --git a/src/app/config/statefile.c b/src/app/config/statefile.c
index d3a0ec179..834ad93ed 100644
--- a/src/app/config/statefile.c
+++ b/src/app/config/statefile.c
@@ -184,6 +184,10 @@ get_state_mgr(void)
   return state_mgr;
 }
 
+#define CHECK_STATE_MAGIC(s) STMT_BEGIN                        \
+    config_check_toplevel_magic(get_state_mgr(), (s));         \
+  STMT_END
+
 /** Persistent serialized state. */
 static or_state_t *global_state = NULL;
 
@@ -286,6 +290,7 @@ or_state_validate_cb(const void *old_state, void *state_, char **msg)
   /* There is not a meaningful concept of a state-to-state transition,
    * since we do not reload the state after we start. */
   (void) old_state;
+  CHECK_STATE_MAGIC(state_);
 
   or_state_t *state = state_;
 



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