[PATCH] json: Avoid calling strlen(NULL)
authorDavid Edmondson <dme@dme.org>
Tue, 6 Apr 2010 07:25:22 +0000 (08:25 +0100)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:36:29 +0000 (09:36 -0800)
28/4a9b5ba9b0497ae8802b292b5cb403401d82e4 [new file with mode: 0644]

diff --git a/28/4a9b5ba9b0497ae8802b292b5cb403401d82e4 b/28/4a9b5ba9b0497ae8802b292b5cb403401d82e4
new file mode 100644 (file)
index 0000000..0840d28
--- /dev/null
@@ -0,0 +1,80 @@
+Return-Path: <dme@dme.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 14C9A4196F4\r
+       for <notmuch@notmuchmail.org>; Tue,  6 Apr 2010 00:25:28 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -1.9\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-1.9 tagged_above=-999 required=5\r
+       tests=[BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001] autolearn=ham\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 8s3XXsbQRGop for <notmuch@notmuchmail.org>;\r
+       Tue,  6 Apr 2010 00:25:27 -0700 (PDT)\r
+Received: from mail-ew0-f219.google.com (mail-ew0-f219.google.com\r
+       [209.85.219.219])\r
+       by olra.theworths.org (Postfix) with ESMTP id 20D3E4196F0\r
+       for <notmuch@notmuchmail.org>; Tue,  6 Apr 2010 00:25:27 -0700 (PDT)\r
+Received: by ewy19 with SMTP id 19so1297787ewy.2\r
+       for <notmuch@notmuchmail.org>; Tue, 06 Apr 2010 00:25:26 -0700 (PDT)\r
+Received: by 10.213.37.195 with SMTP id y3mr356427ebd.72.1270538726007;\r
+       Tue, 06 Apr 2010 00:25:26 -0700 (PDT)\r
+Received: from ut.hh.sledj.net (host83-217-165-81.dsl.vispa.com\r
+       [83.217.165.81])\r
+       by mx.google.com with ESMTPS id p10sm27096353gvf.22.2010.04.06.00.25.23\r
+       (version=TLSv1/SSLv3 cipher=RC4-MD5);\r
+       Tue, 06 Apr 2010 00:25:24 -0700 (PDT)\r
+Received: by ut.hh.sledj.net (Postfix, from userid 1000)\r
+       id 62FBE5941EC; Tue,  6 Apr 2010 08:25:22 +0100 (BST)\r
+To: notmuch <notmuch@notmuchmail.org>\r
+Subject: [PATCH] json: Avoid calling strlen(NULL)\r
+From: David Edmondson <dme@dme.org>\r
+Date: Tue, 06 Apr 2010 08:25:22 +0100\r
+Message-ID: <877holavq5.fsf@ut.hh.sledj.net>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\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: Tue, 06 Apr 2010 07:25:28 -0000\r
+\r
+commit b65817262b3a275ecd0ef1898d92ec5508a9f810\r
+Author: David Edmondson <dme@dme.org>\r
+Date:   Tue Apr 6 08:24:00 2010 +0100\r
+\r
+    json: Avoid calling strlen(NULL)\r
+    \r
+    MIME parts may have no filename, which previously resulted in calling\r
+    strlen(NULL).\r
+\r
+       Modified json.c\r
+diff --git a/json.c b/json.c\r
+index f90b0fa..b73f22a 100644\r
+--- a/json.c\r
++++ b/json.c\r
+@@ -105,5 +105,8 @@ json_quote_chararray(const void *ctx, const char *str, const size_t len)\r
+ char *\r
+ json_quote_str(const void *ctx, const char *str)\r
+ {\r
++    if (str == NULL)\r
++      return (char *)"\"\"";\r
++\r
+     return (json_quote_chararray (ctx, str, strlen (str)));\r
+ }\r
+\r
+\r
+dme.\r
+-- \r
+David Edmondson, http://dme.org\r