diff options
author | Nick Mathewson <nickm@torproject.org> | 2019-10-25 08:08:43 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2019-10-25 08:08:43 -0400 |
commit | aa6b4b62db0ef9e0e9e4c9d716d7b860f8f4a238 (patch) | |
tree | 8a3b5f1c535ff6624085af89a2e259e5511c2dea /src/lib/confmgt | |
parent | 94853b4ab6930b0be92bd3e62ffe761b12493c96 (diff) | |
download | tor-aa6b4b62db0ef9e0e9e4c9d716d7b860f8f4a238.tar.gz tor-aa6b4b62db0ef9e0e9e4c9d716d7b860f8f4a238.zip |
confparse: Add a function to check the magic of a toplevel object.
Diffstat (limited to 'src/lib/confmgt')
-rw-r--r-- | src/lib/confmgt/confparse.c | 11 | ||||
-rw-r--r-- | src/lib/confmgt/confparse.h | 2 |
2 files changed, 13 insertions, 0 deletions
diff --git a/src/lib/confmgt/confparse.c b/src/lib/confmgt/confparse.c index 655fc3483b..b08dc26da8 100644 --- a/src/lib/confmgt/confparse.c +++ b/src/lib/confmgt/confparse.c @@ -334,6 +334,17 @@ config_mgr_list_deprecated_vars(const config_mgr_t *mgr) return result; } +/** + * Check the magic number on <b>object</b> to make sure it's a valid toplevel + * object, created with <b>mgr</b>. Exit with an assertion if it isn't. + **/ +void +config_check_toplevel_magic(const config_mgr_t *mgr, + const void *object) +{ + struct_check_magic(object, &mgr->toplevel_magic); +} + /** Assert that the magic fields in <b>options</b> and its subsidiary * objects are all okay. */ static void diff --git a/src/lib/confmgt/confparse.h b/src/lib/confmgt/confparse.h index 7829f1aeb6..f187bfc38d 100644 --- a/src/lib/confmgt/confparse.h +++ b/src/lib/confmgt/confparse.h @@ -232,6 +232,8 @@ void *config_dup(const config_mgr_t *mgr, const void *old); char *config_dump(const config_mgr_t *mgr, const void *default_options, const void *options, int minimal, int comment_defaults); +void config_check_toplevel_magic(const config_mgr_t *mgr, + const void *object); bool config_check_ok(const config_mgr_t *mgr, const void *options, int severity); int config_assign(const config_mgr_t *mgr, void *options, |