Re: [PATCH v4 13/16] add indexopts to notmuch python bindings.
[notmuch-archives.git] / 21 / 341811f5d9d422925d669e15b03b67d2ebc989
1 Return-Path: <gregor@sam.mediasupervision.de>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5         by olra.theworths.org (Postfix) with ESMTP id 469C2431FC0\r
6         for <notmuch@notmuchmail.org>; Thu,  4 Mar 2010 02:50:00 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -0.987\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.987 tagged_above=-999 required=5\r
12         tests=[AWL=-0.247, BAYES_20=-0.74] autolearn=ham\r
13 Received: from olra.theworths.org ([127.0.0.1])\r
14         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
15         with ESMTP id E6JSnW8M0TsF for <notmuch@notmuchmail.org>;\r
16         Thu,  4 Mar 2010 02:49:59 -0800 (PST)\r
17 Received: from sam.mediasupervision.de (sam.mediasupervision.de\r
18  [80.152.3.104])        by olra.theworths.org (Postfix) with ESMTP id 9CBCB431FBC       for\r
19  <notmuch@notmuchmail.org>; Thu,  4 Mar 2010 02:49:59 -0800 (PST)\r
20 Received: from localhost (sam.mediasupervision.de [127.0.0.1])\r
21         by sam.mediasupervision.de (Postfix) with ESMTP id 97728486291\r
22         for <notmuch@notmuchmail.org>; Thu,  4 Mar 2010 11:49:48 +0100 (CET)\r
23 X-Virus-Scanned: Debian amavisd-new at sam.mediasupervision.de\r
24 Received: from sam.mediasupervision.de ([127.0.0.1])\r
25         by localhost (sam.mediasupervision.de [127.0.0.1]) (amavisd-new,\r
26         port 10024) with ESMTP id IETip9YTnBlK for <notmuch@notmuchmail.org>;\r
27         Thu,  4 Mar 2010 11:49:48 +0100 (CET)\r
28 Received: by sam.mediasupervision.de (Postfix, from userid 1000)\r
29         id 6D223486292; Thu,  4 Mar 2010 11:49:48 +0100 (CET)\r
30 Content-Type: text/plain; charset=UTF-8\r
31 From: Gregor Hoffleit <gregor@hoffleit.de>\r
32 To: notmuch <notmuch@notmuchmail.org>\r
33 Date: Thu, 04 Mar 2010 11:49:48 +0100\r
34 Message-Id: <1267699753-sup-3919@sam.mediasupervision.de>\r
35 User-Agent: Sup/git\r
36 Content-Transfer-Encoding: 8bit\r
37 Subject: [notmuch] [PATCH] format_part_json: part_content->data is not null\r
38         terminated\r
39 X-BeenThere: notmuch@notmuchmail.org\r
40 X-Mailman-Version: 2.1.13\r
41 Precedence: list\r
42 List-Id: "Use and development of the notmuch mail system."\r
43         <notmuch.notmuchmail.org>\r
44 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
45         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
46 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
47 List-Post: <mailto:notmuch@notmuchmail.org>\r
48 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
49 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
50         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
51 X-List-Received-Date: Thu, 04 Mar 2010 10:50:00 -0000\r
52 \r
53 In format_part_json, part_content->data is not a null terminated string.\r
54 Instead, we have to use part_content->len.\r
55 ---\r
56  notmuch-show.c |    7 ++++++-\r
57  1 files changed, 6 insertions(+), 1 deletions(-)\r
58 \r
59 diff --git a/notmuch-show.c b/notmuch-show.c\r
60 index 1a1d601..4b755e9 100644\r
61 --- a/notmuch-show.c\r
62 +++ b/notmuch-show.c\r
63 @@ -309,10 +309,15 @@ format_part_json (GMimeObject *part, int *part_count)\r
64      if (g_mime_content_type_is_type (content_type, "text", "*") &&\r
65         !g_mime_content_type_is_type (content_type, "text", "html"))\r
66      {\r
67 +       char *content_data;\r
68 +\r
69         show_part_content (part, stream_memory);\r
70         part_content = g_mime_stream_mem_get_byte_array (GMIME_STREAM_MEM (stream_memory));\r
71  \r
72 -       printf (", \"content\": %s", json_quote_str (ctx, (char *) part_content->data));\r
73 +       content_data = talloc_size (ctx, part_content->len+1);\r
74 +       memcpy (content_data, (char *)part_content->data, part_content->len+1);\r
75 +       content_data[part_content->len] = 0;\r
76 +       printf (", \"content\": %s", json_quote_str (ctx, content_data));\r
77      }\r
78  \r
79      fputs ("}", stdout);\r
80 -- \r
81 1.7.0\r