aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Jani Nikula <jani@nikula.org>2012-01-05 22:25:12 +0200
committerGravatar David Bremner <bremner@debian.org>2012-01-09 06:50:20 -0400
commit80ae1829c19f1fbe714232defcf12f18bc99ddb8 (patch)
treec84cec8cc8e6e36dac28d16f12b078e61e070368
parente0991930c0ffe25db6fe3769b938df261dbc6531 (diff)
cli: fix use of uninitialized variable in "notmuch reply"
notmuch_show_params_t params is only initialized partially in notmuch_reply_command(). The only field that is used uninitialized is params.decrypt. It is usually non-zero, making "notmuch reply" on encrypted messages work by coincidence. Initialize params properly, and set params.decrypt as needed. Signed-off-by: Jani Nikula <jani@nikula.org>
-rw-r--r--notmuch-reply.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/notmuch-reply.c b/notmuch-reply.c
index 7ac879f9..7242310a 100644
--- a/notmuch-reply.c
+++ b/notmuch-reply.c
@@ -622,11 +622,9 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])
char *opt, *query_string;
int i, ret = 0;
int (*reply_format_func)(void *ctx, notmuch_config_t *config, notmuch_query_t *query, notmuch_show_params_t *params);
- notmuch_show_params_t params;
+ notmuch_show_params_t params = { .part = -1 };
reply_format_func = notmuch_reply_format_default;
- params.part = -1;
- params.cryptoctx = NULL;
argc--; argv++; /* skip subcommand argument */
@@ -648,10 +646,12 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])
} else if ((STRNCMP_LITERAL (argv[i], "--decrypt") == 0)) {
if (params.cryptoctx == NULL) {
GMimeSession* session = g_object_new(g_mime_session_get_type(), NULL);
- if (NULL == (params.cryptoctx = g_mime_gpg_context_new(session, "gpg")))
+ if (NULL == (params.cryptoctx = g_mime_gpg_context_new(session, "gpg"))) {
fprintf (stderr, "Failed to construct gpg context.\n");
- else
+ } else {
+ params.decrypt = TRUE;
g_mime_gpg_context_set_always_trust((GMimeGpgContext*)params.cryptoctx, FALSE);
+ }
g_object_unref (session);
session = NULL;
}