Re: [PATCH v3 4/6] cli: sanitize the received header before scanning for replies
authorAustin Clements <amdragon@MIT.EDU>
Mon, 3 Feb 2014 20:46:12 +0000 (15:46 +1900)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:59:40 +0000 (09:59 -0800)
2c/595180ab8b73dec0e1ea4c0f1c12ec911b8fc6 [new file with mode: 0644]

diff --git a/2c/595180ab8b73dec0e1ea4c0f1c12ec911b8fc6 b/2c/595180ab8b73dec0e1ea4c0f1c12ec911b8fc6
new file mode 100644 (file)
index 0000000..1f47993
--- /dev/null
@@ -0,0 +1,131 @@
+Return-Path: <amdragon@mit.edu>\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 955E9431FBC\r
+       for <notmuch@notmuchmail.org>; Mon,  3 Feb 2014 12:46:25 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\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 C97kxAQTWejO for <notmuch@notmuchmail.org>;\r
+       Mon,  3 Feb 2014 12:46:19 -0800 (PST)\r
+Received: from dmz-mailsec-scanner-3.mit.edu (dmz-mailsec-scanner-3.mit.edu\r
+       [18.9.25.14])\r
+       (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id 3D22C431FAF\r
+       for <notmuch@notmuchmail.org>; Mon,  3 Feb 2014 12:46:19 -0800 (PST)\r
+X-AuditID: 1209190e-f79ee6d000000c40-89-52f0001abacd\r
+Received: from mailhub-auth-3.mit.edu ( [18.9.21.43])\r
+       (using TLS with cipher AES256-SHA (256/256 bits))\r
+       (Client did not present a certificate)\r
+       by dmz-mailsec-scanner-3.mit.edu (Symantec Messaging Gateway) with SMTP\r
+       id FA.EB.03136.A1000F25; Mon,  3 Feb 2014 15:46:18 -0500 (EST)\r
+Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11])\r
+       by mailhub-auth-3.mit.edu (8.13.8/8.9.2) with ESMTP id s13KkGRF023224; \r
+       Mon, 3 Feb 2014 15:46:17 -0500\r
+Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91])\r
+       (authenticated bits=0)\r
+       (User authenticated as amdragon@ATHENA.MIT.EDU)\r
+       by outgoing.mit.edu (8.13.8/8.12.4) with ESMTP id s13KkDYF024333\r
+       (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NOT);\r
+       Mon, 3 Feb 2014 15:46:15 -0500\r
+Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.80)\r
+       (envelope-from <amdragon@mit.edu>)\r
+       id 1WAQPE-0002Qm-Ud; Mon, 03 Feb 2014 15:46:13 -0500\r
+Date: Mon, 3 Feb 2014 15:46:12 -0500\r
+From: Austin Clements <amdragon@MIT.EDU>\r
+To: Jani Nikula <jani@nikula.org>\r
+Subject: Re: [PATCH v3 4/6] cli: sanitize the received header before scanning\r
+       for replies\r
+Message-ID: <20140203204611.GL4375@mit.edu>\r
+References: <cover.1391456555.git.jani@nikula.org>\r
+       <df154611af9e23ef443f56c5abb90c8b276b18e7.1391456555.git.jani@nikula.org>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\r
+Content-Disposition: inline\r
+In-Reply-To:\r
+ <df154611af9e23ef443f56c5abb90c8b276b18e7.1391456555.git.jani@nikula.org>\r
+User-Agent: Mutt/1.5.21 (2010-09-15)\r
+X-Brightmail-Tracker:\r
+ H4sIAAAAAAAAA+NgFmpmleLIzCtJLcpLzFFi42IR4hTV1pVi+BBk0LFWwKJpurPF9ZszmR2Y\r
+       PG7df83u8WzVLeYApigum5TUnMyy1CJ9uwSujOM/OxgLVnBXnGx4ydzAeJ+ji5GTQ0LAROJN\r
+       fzsrhC0mceHeerYuRi4OIYHZTBKrP/+AcjYwSnzdcAfKOcUk8eH4UyYIZwmjxP9/08D6WQRU\r
+       JPomrWcEsdkENCS27V8OZosIKEpsPrkfzGYWkJb49ruZCcQWFoiWOPv+NFicV0Bb4s3MPrC4\r
+       kECdxNXWmywQcUGJkzOfsED0aknc+PcSqIYDbM7yf2AvcAqESWxYOJcZxBYFOmHKyW1sExiF\r
+       ZiHpnoWkexZC9wJG5lWMsim5Vbq5iZk5xanJusXJiXl5qUW6xnq5mSV6qSmlmxjBYS3Jt4Px\r
+       60GlQ4wCHIxKPLwde98FCbEmlhVX5h5ilORgUhLlzfnzPkiILyk/pTIjsTgjvqg0J7X4EKME\r
+       B7OSCK/fJ6Acb0piZVVqUT5MSpqDRUmcN3HGmyAhgfTEktTs1NSC1CKYrAwHh5IEr9x/oEbB\r
+       otT01Iq0zJwShDQTByfIcB6g4VX/QIYXFyTmFmemQ+RPMSpKifOagzQLgCQySvPgemFp5xWj\r
+       ONArwrx3Qdp5gCkLrvsV0GAmoMHrXMEGlyQipKQaGCvUnmRbvjOvaNnO5MRSWhm0vUvo19uX\r
+       4UpBHX8u7feNuna7vfzqbuHZDtqdxzikDuQxFq48n6O35GtihMTCwI7JGu/1RWS35h97O22+\r
+       cZ/V/i1W1cfOFl6pX3pWafV9xjUV32Ys/Vjiy37+nKy7+MET1mqJHVGCckf77s3d0Ve0NqC1\r
+       8fZkByWW4oxEQy3mouJEAL2Whm4WAwAA\r
+Cc: notmuch@notmuchmail.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: Mon, 03 Feb 2014 20:46:25 -0000\r
+\r
+Quoth Jani Nikula on Feb 03 at  9:51 pm:\r
+> This makes the from guessing agnostic to header folding by spaces or\r
+> tabs.\r
+> ---\r
+>  notmuch-reply.c | 12 ++++++++++--\r
+>  1 file changed, 10 insertions(+), 2 deletions(-)\r
+> \r
+> diff --git a/notmuch-reply.c b/notmuch-reply.c\r
+> index 47993d2..3f7021e 100644\r
+> --- a/notmuch-reply.c\r
+> +++ b/notmuch-reply.c\r
+> @@ -21,6 +21,7 @@\r
+>   */\r
+>  \r
+>  #include "notmuch-client.h"\r
+> +#include "string-util.h"\r
+>  #include "sprinter.h"\r
+>  \r
+>  static void\r
+> @@ -465,14 +466,21 @@ guess_from_in_received_headers (notmuch_config_t *config,\r
+>                              notmuch_message_t *message)\r
+>  {\r
+>      const char *received, *addr;\r
+> +    char *sanitized;\r
+>  \r
+>      received = notmuch_message_get_header (message, "received");\r
+>      if (! received)\r
+>      return NULL;\r
+>  \r
+> -    addr = guess_from_in_received_for (config, received);\r
+> +    sanitized = sanitize_string (config, received);\r
+\r
+Did you mean to pass "config" as the talloc context for\r
+sanitize_string?  It seems like a better context would be "message" or\r
+possibly even NULL, given that you explicitly talloc_free the string.\r
+\r
+> +    if (! sanitized)\r
+> +    return NULL;\r
+> +\r
+> +    addr = guess_from_in_received_for (config, sanitized);\r
+>      if (! addr)\r
+> -    addr = guess_from_in_received_by (config, received);\r
+> +    addr = guess_from_in_received_by (config, sanitized);\r
+> +\r
+> +    talloc_free (sanitized);\r
+>  \r
+>      return addr;\r
+>  }\r