Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id B4B8D42116D for ; Thu, 5 Jan 2012 12:25:27 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References" X-Spam-Flag: NO X-Spam-Score: -0.7 X-Spam-Level: X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id KCJYxzUhEbSl for ; Thu, 5 Jan 2012 12:25:26 -0800 (PST) Received: from mail-ee0-f53.google.com (mail-ee0-f53.google.com [74.125.83.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 0F7B8429E31 for ; Thu, 5 Jan 2012 12:25:23 -0800 (PST) Received: by mail-ee0-f53.google.com with SMTP id d41so756745eek.26 for ; Thu, 05 Jan 2012 12:25:23 -0800 (PST) Received: by 10.213.105.75 with SMTP id s11mr715924ebo.8.1325795123220; Thu, 05 Jan 2012 12:25:23 -0800 (PST) Received: from localhost (dsl-hkibrasgw4-fe5cdc00-23.dhcp.inet.fi. [80.220.92.23]) by mx.google.com with ESMTPS id q67sm176207998eea.8.2012.01.05.12.25.21 (version=SSLv3 cipher=OTHER); Thu, 05 Jan 2012 12:25:22 -0800 (PST) From: Jani Nikula To: notmuch@notmuchmail.org, david@tethera.net Subject: [PATCH 1/4] cli: fix use of uninitialized variable in "notmuch reply" Date: Thu, 5 Jan 2012 22:25:12 +0200 Message-Id: <974a2ef1f1df7d93e0b5bd642ca8a49f8b727a86.1325794371.git.jani@nikula.org> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: References: In-Reply-To: References: X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 Jan 2012 20:25:28 -0000 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 --- notmuch-reply.c | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-) diff --git a/notmuch-reply.c b/notmuch-reply.c index f8d5f64..1f33a86 100644 --- a/notmuch-reply.c +++ b/notmuch-reply.c @@ -621,11 +621,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 */ @@ -647,10 +645,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; } -- 1.7.5.4