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 469C2431FC0 for ; Thu, 4 Mar 2010 02:50:00 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.987 X-Spam-Level: X-Spam-Status: No, score=-0.987 tagged_above=-999 required=5 tests=[AWL=-0.247, BAYES_20=-0.74] 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 E6JSnW8M0TsF for ; Thu, 4 Mar 2010 02:49:59 -0800 (PST) Received: from sam.mediasupervision.de (sam.mediasupervision.de [80.152.3.104]) by olra.theworths.org (Postfix) with ESMTP id 9CBCB431FBC for ; Thu, 4 Mar 2010 02:49:59 -0800 (PST) Received: from localhost (sam.mediasupervision.de [127.0.0.1]) by sam.mediasupervision.de (Postfix) with ESMTP id 97728486291 for ; Thu, 4 Mar 2010 11:49:48 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at sam.mediasupervision.de Received: from sam.mediasupervision.de ([127.0.0.1]) by localhost (sam.mediasupervision.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id IETip9YTnBlK for ; Thu, 4 Mar 2010 11:49:48 +0100 (CET) Received: by sam.mediasupervision.de (Postfix, from userid 1000) id 6D223486292; Thu, 4 Mar 2010 11:49:48 +0100 (CET) Content-Type: text/plain; charset=UTF-8 From: Gregor Hoffleit To: notmuch Date: Thu, 04 Mar 2010 11:49:48 +0100 Message-Id: <1267699753-sup-3919@sam.mediasupervision.de> User-Agent: Sup/git Content-Transfer-Encoding: 8bit Subject: [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, 04 Mar 2010 10:50:00 -0000 In format_part_json, part_content->data is not a null terminated string. Instead, we have to use part_content->len. --- notmuch-show.c | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-) diff --git a/notmuch-show.c b/notmuch-show.c index 1a1d601..4b755e9 100644 --- a/notmuch-show.c +++ b/notmuch-show.c @@ -309,10 +309,15 @@ format_part_json (GMimeObject *part, int *part_count) if (g_mime_content_type_is_type (content_type, "text", "*") && !g_mime_content_type_is_type (content_type, "text", "html")) { + char *content_data; + show_part_content (part, stream_memory); part_content = g_mime_stream_mem_get_byte_array (GMIME_STREAM_MEM (stream_memory)); - 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)); } fputs ("}", stdout); -- 1.7.0