[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [tor/master] confparse: Add a function to check the magic of a toplevel object.
commit aa6b4b62db0ef9e0e9e4c9d716d7b860f8f4a238
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date: Fri Oct 25 08:08:43 2019 -0400
confparse: Add a function to check the magic of a toplevel object.
---
src/lib/confmgt/confparse.c | 11 +++++++++++
src/lib/confmgt/confparse.h | 2 ++
2 files changed, 13 insertions(+)
diff --git a/src/lib/confmgt/confparse.c b/src/lib/confmgt/confparse.c
index 655fc3483..b08dc26da 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 7829f1aeb..f187bfc38 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,
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits