From: Michal Sojka Date: Thu, 1 Apr 2010 12:05:06 +0000 (+0200) Subject: Re: [notmuch] [PATCH] format_part_json: part_content->data is not null terminated X-Git-Url: http://git.tremily.us/?p=notmuch-archives.git;a=commitdiff_plain;h=a7f4a7c14a64e5a70c421aae1a2c45e62b93b73a Re: [notmuch] [PATCH] format_part_json: part_content->data is not null terminated --- diff --git a/90/95e4c52089103a7adc888636f5cbeeab699a05 b/90/95e4c52089103a7adc888636f5cbeeab699a05 new file mode 100644 index 000000000..58030e516 --- /dev/null +++ b/90/95e4c52089103a7adc888636f5cbeeab699a05 @@ -0,0 +1,76 @@ +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 153864196F0 + for ; Thu, 1 Apr 2010 05:05:11 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -1.9 +X-Spam-Level: +X-Spam-Status: No, score=-1.9 tagged_above=-999 required=5 + tests=[BAYES_00=-1.9] autolearn=ham +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 WV8kxvgmGg0l for ; + Thu, 1 Apr 2010 05:05:10 -0700 (PDT) +Received: from max.feld.cvut.cz (max.feld.cvut.cz [147.32.192.36]) + by olra.theworths.org (Postfix) with ESMTP id 5ABC3431FC1 + for ; Thu, 1 Apr 2010 05:05:10 -0700 (PDT) +Received: from localhost (unknown [192.168.200.4]) + by max.feld.cvut.cz (Postfix) with ESMTP id 3BB9519F35D1; + Thu, 1 Apr 2010 14:05:09 +0200 (CEST) +X-Virus-Scanned: IMAP AMAVIS +Received: from max.feld.cvut.cz ([192.168.200.1]) + by localhost (styx.feld.cvut.cz [192.168.200.4]) (amavisd-new, + port 10044) + with ESMTP id JjTmf-aHcwQX; Thu, 1 Apr 2010 14:05:07 +0200 (CEST) +Received: from imap.feld.cvut.cz (imap.feld.cvut.cz [147.32.192.34]) + by max.feld.cvut.cz (Postfix) with ESMTP id EF51819F33C6; + Thu, 1 Apr 2010 14:05:06 +0200 (CEST) +Received: from steelpick.2x.cz (k335-30.felk.cvut.cz [147.32.86.30]) + (Authenticated sender: sojkam1) + by imap.feld.cvut.cz (Postfix) with ESMTPSA id A65B4FA003; + Thu, 1 Apr 2010 14:05:06 +0200 (CEST) +Received: from wsh by steelpick.2x.cz with local (Exim 4.71) + (envelope-from ) + id 1NxJ90-0004YW-AD; Thu, 01 Apr 2010 14:05:06 +0200 +From: Michal Sojka +To: David Edmondson , David Bremner , + Gregor Hoffleit , notmuch +In-Reply-To: <87634bjsrl.fsf@ut.hh.sledj.net> +References: <1267699753-sup-3919@sam.mediasupervision.de> + <871vezs8ne.fsf@rocinante.cs.unb.ca> + <87634bjsrl.fsf@ut.hh.sledj.net> +Date: Thu, 01 Apr 2010 14:05:06 +0200 +Message-ID: <874ojv5qfh.fsf@steelpick.2x.cz> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Subject: Re: [notmuch] [PATCH] format_part_json: part_content->data is not + null terminated +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, 01 Apr 2010 12:05:11 -0000 + +On Thu, 04 Mar 2010, Gregor Hoffleit wrote: +> - printf (", \"content\": %s", json_quote_str (ctx, (char *) part_content->data)); +> + content_data = talloc_size (ctx, part_content->len+1); +> + memcpy (content_data, (char *)part_content->data, part_content->len+1); +> + content_data[part_content->len] = 0; +> + printf (", \"content\": %s", json_quote_str (ctx, content_data)); + +What about modifying json_quote_str() to accept additional parameter +len? If I have 10MB attachment to the email, this unnecessary copy is +quite expensive, isn't it? + +--Michal