[PATCH v2 1/6] cli: fix use of uninitialized variable in "notmuch reply"
authorJani Nikula <jani@nikula.org>
Sun, 8 Jan 2012 21:48:30 +0000 (23:48 +0200)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:41:46 +0000 (09:41 -0800)
e0/9a1e1198d42da544f47c83f754e2678398d2e6 [new file with mode: 0644]

diff --git a/e0/9a1e1198d42da544f47c83f754e2678398d2e6 b/e0/9a1e1198d42da544f47c83f754e2678398d2e6
new file mode 100644 (file)
index 0000000..743aecb
--- /dev/null
@@ -0,0 +1,104 @@
+Return-Path: <jani@nikula.org>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id 9D72B4150E6\r
+       for <notmuch@notmuchmail.org>; Sun,  8 Jan 2012 13:48:49 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References"\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.7\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
+       tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id zkKn-TrI1rQv for <notmuch@notmuchmail.org>;\r
+       Sun,  8 Jan 2012 13:48:48 -0800 (PST)\r
+Received: from mail-ee0-f53.google.com (mail-ee0-f53.google.com\r
+ [74.125.83.53])       (using TLSv1 with cipher RC4-SHA (128/128 bits))        (No client\r
+ certificate requested)        by olra.theworths.org (Postfix) with ESMTPS id\r
+ 861F24150E5   for <notmuch@notmuchmail.org>; Sun,  8 Jan 2012 13:48:48 -0800\r
+ (PST)\r
+Received: by mail-ee0-f53.google.com with SMTP id d41so2496075eek.26\r
+       for <notmuch@notmuchmail.org>; Sun, 08 Jan 2012 13:48:48 -0800 (PST)\r
+Received: by 10.14.100.10 with SMTP id y10mr5167890eef.119.1326059328120;\r
+       Sun, 08 Jan 2012 13:48:48 -0800 (PST)\r
+Received: from localhost (dsl-hkibrasgw4-fe5cdc00-23.dhcp.inet.fi.\r
+       [80.220.92.23])\r
+       by mx.google.com with ESMTPS id 76sm282304492eeh.0.2012.01.08.13.48.45\r
+       (version=SSLv3 cipher=OTHER); Sun, 08 Jan 2012 13:48:46 -0800 (PST)\r
+From: Jani Nikula <jani@nikula.org>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v2 1/6] cli: fix use of uninitialized variable in "notmuch\r
+       reply"\r
+Date: Sun,  8 Jan 2012 23:48:30 +0200\r
+Message-Id:\r
+ <974a2ef1f1df7d93e0b5bd642ca8a49f8b727a86.1326058946.git.jani@nikula.org>\r
+X-Mailer: git-send-email 1.7.5.4\r
+In-Reply-To: <cover.1326058946.git.jani@nikula.org>\r
+References: <cover.1326058946.git.jani@nikula.org>\r
+In-Reply-To: <cover.1326058946.git.jani@nikula.org>\r
+References: <cover.1325794371.git.jani@nikula.org>\r
+       <cover.1326058946.git.jani@nikula.org>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Sun, 08 Jan 2012 21:48:49 -0000\r
+\r
+notmuch_show_params_t params is only initialized partially in\r
+notmuch_reply_command(). The only field that is used uninitialized is\r
+params.decrypt. It is usually non-zero, making "notmuch reply" on encrypted\r
+messages work by coincidence.\r
+\r
+Initialize params properly, and set params.decrypt as needed.\r
+\r
+Signed-off-by: Jani Nikula <jani@nikula.org>\r
+---\r
+ notmuch-reply.c |   10 +++++-----\r
+ 1 files changed, 5 insertions(+), 5 deletions(-)\r
+\r
+diff --git a/notmuch-reply.c b/notmuch-reply.c\r
+index f8d5f64..1f33a86 100644\r
+--- a/notmuch-reply.c\r
++++ b/notmuch-reply.c\r
+@@ -621,11 +621,9 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])\r
+     char *opt, *query_string;\r
+     int i, ret = 0;\r
+     int (*reply_format_func)(void *ctx, notmuch_config_t *config, notmuch_query_t *query, notmuch_show_params_t *params);\r
+-    notmuch_show_params_t params;\r
++    notmuch_show_params_t params = { .part = -1 };\r
\r
+     reply_format_func = notmuch_reply_format_default;\r
+-    params.part = -1;\r
+-    params.cryptoctx = NULL;\r
\r
+     argc--; argv++; /* skip subcommand argument */\r
\r
+@@ -647,10 +645,12 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])\r
+       } else if ((STRNCMP_LITERAL (argv[i], "--decrypt") == 0)) {\r
+           if (params.cryptoctx == NULL) {\r
+               GMimeSession* session = g_object_new(g_mime_session_get_type(), NULL);\r
+-              if (NULL == (params.cryptoctx = g_mime_gpg_context_new(session, "gpg")))\r
++              if (NULL == (params.cryptoctx = g_mime_gpg_context_new(session, "gpg"))) {\r
+                   fprintf (stderr, "Failed to construct gpg context.\n");\r
+-              else\r
++              } else {\r
++                  params.decrypt = TRUE;\r
+                   g_mime_gpg_context_set_always_trust((GMimeGpgContext*)params.cryptoctx, FALSE);\r
++              }\r
+               g_object_unref (session);\r
+               session = NULL;\r
+           }\r
+-- \r
+1.7.5.4\r
+\r