]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
confparse: Add a function to check the magic of a toplevel object.
authorNick Mathewson <nickm@torproject.org>
Fri, 25 Oct 2019 12:08:43 +0000 (08:08 -0400)
committerNick Mathewson <nickm@torproject.org>
Fri, 25 Oct 2019 12:08:43 +0000 (08:08 -0400)
src/lib/confmgt/confparse.c
src/lib/confmgt/confparse.h

index 655fc3483b2e1f4368aaa099c3b6cab3a10c7722..b08dc26da8c8854ada0ae6365c860db9e74a6483 100644 (file)
@@ -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
index 7829f1aeb6e4bd0e896bd9a7553d22014b2de370..f187bfc38d0a9e534c03e124762617811b4b8a1b 100644 (file)
@@ -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,