[Pkg-gnupg-commit] [gnupg2] 100/124: gpg: Assert that an opaque parameter is really what we expect.
Daniel Kahn Gillmor
dkg at fifthhorseman.net
Wed Apr 5 15:55:37 UTC 2017
This is an automated email from the git hooks/post-receive script.
dkg pushed a commit to branch experimental
in repository gnupg2.
commit 52ba5e67cad4311d0ddbc4f2979e20afd0161d1f
Author: Werner Koch <wk at gnupg.org>
Date: Fri Mar 31 20:06:54 2017 +0200
gpg: Assert that an opaque parameter is really what we expect.
* g10/gpg.h (SERVER_CONTROL_MAGIC): New const.
(server_control_s): Add field 'magic'.
* g10/gpg.c (gpg_init_default_ctrl): Init MAGIC.
* g10/import.c (impex_filter_getval): Assert MAGIC.
Signed-off-by: Werner Koch <wk at gnupg.org>
---
g10/gpg.c | 2 +-
g10/gpg.h | 9 +++++++++
g10/import.c | 2 ++
3 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/g10/gpg.c b/g10/gpg.c
index 28e0a9c..c9ae28c 100644
--- a/g10/gpg.c
+++ b/g10/gpg.c
@@ -2182,7 +2182,7 @@ set_compliance_option (enum cmd_and_opt_values option)
static void
gpg_init_default_ctrl (ctrl_t ctrl)
{
- (void)ctrl;
+ ctrl->magic = SERVER_CONTROL_MAGIC;
}
diff --git a/g10/gpg.h b/g10/gpg.h
index 3bf023b..c663585 100644
--- a/g10/gpg.h
+++ b/g10/gpg.h
@@ -68,11 +68,20 @@ struct tofu_dbs_s;
typedef struct tofu_dbs_s *tofu_dbs_t;
+#if SIZEOF_UNSIGNED_LONG == 8
+# define SERVER_CONTROL_MAGIC 0x53616c696e676572
+#else
+# define SERVER_CONTROL_MAGIC 0x53616c69
+#endif
+
/* Session control object. This object is passed to most functions to
convey the status of a session. Note that the defaults are set by
gpg_init_default_ctrl(). */
struct server_control_s
{
+ /* Always has the value SERVER_CONTROL_MAGIC. */
+ unsigned long magic;
+
/* Local data for server.c */
struct server_local_s *server_local;
diff --git a/g10/import.c b/g10/import.c
index abc811d..54d649b 100644
--- a/g10/import.c
+++ b/g10/import.c
@@ -1182,6 +1182,8 @@ impex_filter_getval (void *cookie, const char *propname)
static char numbuf[20];
const char *result;
+ log_assert (ctrl && ctrl->magic == SERVER_CONTROL_MAGIC);
+
if (node->pkt->pkttype == PKT_USER_ID
|| node->pkt->pkttype == PKT_ATTRIBUTE)
{
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-gnupg/gnupg2.git
More information about the Pkg-gnupg-commit
mailing list