Re: [PATCH] json: Avoid calling strlen(NULL)
authorCarl Worth <cworth@cworth.org>
Tue, 20 Apr 2010 15:59:52 +0000 (08:59 +1700)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:36:44 +0000 (09:36 -0800)
b2/2526380961b9bdd5dd17a83d69f49cc10aa587 [new file with mode: 0644]

diff --git a/b2/2526380961b9bdd5dd17a83d69f49cc10aa587 b/b2/2526380961b9bdd5dd17a83d69f49cc10aa587
new file mode 100644 (file)
index 0000000..925a47d
--- /dev/null
@@ -0,0 +1,88 @@
+Return-Path: <cworth@cworth.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 A0C284196F2\r
+       for <notmuch@notmuchmail.org>; Tue, 20 Apr 2010 08:59:52 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -2.89\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-2.89 tagged_above=-999 required=5\r
+       tests=[ALL_TRUSTED=-1, BAYES_00=-1.9, T_MIME_NO_TEXT=0.01]\r
+       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 TZIevhlelrAr; Tue, 20 Apr 2010 08:59:51 -0700 (PDT)\r
+Received: from yoom.home.cworth.org (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id 4ED35431FC1;\r
+       Tue, 20 Apr 2010 08:59:51 -0700 (PDT)\r
+Received: by yoom.home.cworth.org (Postfix, from userid 1000)\r
+       id 6CA6525400A; Tue, 20 Apr 2010 08:59:52 -0700 (PDT)\r
+From: Carl Worth <cworth@cworth.org>\r
+To: Anthony Towns <aj@erisian.com.au>, David Edmondson <dme@dme.org>\r
+Subject: Re: [PATCH] json: Avoid calling strlen(NULL)\r
+In-Reply-To: <h2y87b3a4191004060117v5421db8ejbe3030d0626e7440@mail.gmail.com>\r
+References: <877holavq5.fsf@ut.hh.sledj.net>\r
+       <h2y87b3a4191004060117v5421db8ejbe3030d0626e7440@mail.gmail.com>\r
+Date: Tue, 20 Apr 2010 08:59:52 -0700\r
+Message-ID: <878w8iw1vr.fsf@yoom.home.cworth.org>\r
+MIME-Version: 1.0\r
+Content-Type: multipart/signed; boundary="=-=-=";\r
+       micalg=pgp-sha1; protocol="application/pgp-signature"\r
+Cc: notmuch <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: Tue, 20 Apr 2010 15:59:52 -0000\r
+\r
+--=-=-=\r
+Content-Transfer-Encoding: quoted-printable\r
+\r
+> There's already a check in json_quote_chararray for len=3D=3D0, so it\r
+> might be sensible to say:\r
+>=20\r
+>     return (json_quote_chararray (ctx, str, str !=3D NULL ? strlen (str) =\r
+: 0));\r
+>=20\r
+> OTOH, the code in json_quote_array to deal with that does the same\r
+> thing (returns a literal string containing two quote marks), which\r
+> seems wrong -- the normal code path is to talloc to get a newly\r
+> allocated, editable string, that might be talloc_free'd later,\r
+> wouldn't it make more sense just to let the str=3D=3DNULL / len=3D=3D0\r
+> behaviour fall through into the normal case code?\r
+\r
+Yes, that's the correct analysis. Thanks so much.\r
+\r
+> commit 5b93a488221b50c02db18d86a550cb3c038c00da\r
+> Author: Anthony <aj@erisian.com.au>\r
+> Date:   Tue Apr 6 18:10:39 2010 +1000\r
+>=20\r
+>     json: Avoid calling strlen(NULL), and always return a newly\r
+>     talloced array.\r
+\r
+\r
+I've pushed this out now, (separated into two pieces).\r
+\r
+=2DCarl\r
+\r
+--=-=-=\r
+Content-Type: application/pgp-signature\r
+\r
+-----BEGIN PGP SIGNATURE-----\r
+Version: GnuPG v1.4.10 (GNU/Linux)\r
+\r
+iD8DBQFLzc946JDdNq8qSWgRAsP1AJ9fgpBe6+hZRrq8FRJV3l50kzpv8QCfcal/\r
+i0IWzEcB2C/hBqtiZ3VIu2Q=\r
+=N51E\r
+-----END PGP SIGNATURE-----\r
+--=-=-=--\r