diff options
author | Nick Mathewson <nickm@torproject.org> | 2019-10-25 08:09:05 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2019-10-25 08:09:05 -0400 |
commit | 63f2a310cbeb5908a202ba17da7e66535c77c894 (patch) | |
tree | d91dcad494b9d3e0333d6417a776a5f4c2eb7675 /src/app/config | |
parent | aa6b4b62db0ef9e0e9e4c9d716d7b860f8f4a238 (diff) | |
download | tor-63f2a310cbeb5908a202ba17da7e66535c77c894.tar.gz tor-63f2a310cbeb5908a202ba17da7e66535c77c894.zip |
config,state: check magic in all callbacks.
Diffstat (limited to 'src/app/config')
-rw-r--r-- | src/app/config/config.c | 11 | ||||
-rw-r--r-- | src/app/config/statefile.c | 5 |
2 files changed, 16 insertions, 0 deletions
diff --git a/src/app/config/config.c b/src/app/config/config.c index b6927b8b77..f2db0e5250 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 d3a0ec1790..834ad93ed7 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_; |