Re: [PATCH] emacs: wash: make word-wrap bound message width
[notmuch-archives.git] / ac / 2dacc370363799e428869e0a4cb56890732a22
1 Return-Path: <m.walters@qmul.ac.uk>\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 54F99431FAF\r
6         for <notmuch@notmuchmail.org>; Wed,  8 Aug 2012 14:23:46 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -1.098\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-1.098 tagged_above=-999 required=5\r
12         tests=[DKIM_ADSP_CUSTOM_MED=0.001, FREEMAIL_FROM=0.001,\r
13         NML_ADSP_CUSTOM_MED=1.2, RCVD_IN_DNSWL_MED=-2.3] autolearn=disabled\r
14 Received: from olra.theworths.org ([127.0.0.1])\r
15         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
16         with ESMTP id 1+jqppWpAjqF for <notmuch@notmuchmail.org>;\r
17         Wed,  8 Aug 2012 14:23:45 -0700 (PDT)\r
18 Received: from mail2.qmul.ac.uk (mail2.qmul.ac.uk [138.37.6.6])\r
19         (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\r
20         (No client certificate requested)\r
21         by olra.theworths.org (Postfix) with ESMTPS id 7BFDF431FAE\r
22         for <notmuch@notmuchmail.org>; Wed,  8 Aug 2012 14:23:45 -0700 (PDT)\r
23 Received: from smtp.qmul.ac.uk ([138.37.6.40])\r
24         by mail2.qmul.ac.uk with esmtp (Exim 4.71)\r
25         (envelope-from <m.walters@qmul.ac.uk>)\r
26         id 1SzDjA-0003DQ-Ot; Wed, 08 Aug 2012 22:23:41 +0100\r
27 Received: from 94-192-233-223.zone6.bethere.co.uk ([94.192.233.223]\r
28         helo=localhost)\r
29         by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.69)\r
30         (envelope-from <m.walters@qmul.ac.uk>)\r
31         id 1SzDjA-0004T9-EB; Wed, 08 Aug 2012 22:23:40 +0100\r
32 From: Mark Walters <markwalters1009@gmail.com>\r
33 To: Austin Clements <amdragon@MIT.EDU>, notmuch@notmuchmail.org\r
34 Subject: [PATCH] sprinters: bugfix when NULL passed for a string.\r
35 In-Reply-To: <1344389313-7886-1-git-send-email-amdragon@mit.edu>\r
36 References: <1344374501-28185-1-git-send-email-amdragon@mit.edu>\r
37         <1344389313-7886-1-git-send-email-amdragon@mit.edu>\r
38 User-Agent: Notmuch/0.13.2+96~g634443c (http://notmuchmail.org) Emacs/23.4.1\r
39         (x86_64-pc-linux-gnu)\r
40 Date: Wed, 08 Aug 2012 22:23:33 +0100\r
41 Message-ID: <87mx25ulgq.fsf@qmul.ac.uk>\r
42 MIME-Version: 1.0\r
43 Content-Type: text/plain; charset=us-ascii\r
44 X-Sender-Host-Address: 94.192.233.223\r
45 X-QM-SPAM-Info: Sender has good ham record.  :)\r
46 X-QM-Body-MD5: fdbcd46c1208c4a38bcc75ec23a98fe0 (of first 20000 bytes)\r
47 X-SpamAssassin-Score: -1.8\r
48 X-SpamAssassin-SpamBar: -\r
49 X-SpamAssassin-Report: The QM spam filters have analysed this message to\r
50         determine if it is\r
51         spam. We require at least 5.0 points to mark a message as spam.\r
52         This message scored -1.8 points.\r
53         Summary of the scoring: \r
54         * -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/,\r
55         *      medium trust\r
56         *      [138.37.6.40 listed in list.dnswl.org]\r
57         * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail\r
58         provider *      (markwalters1009[at]gmail.com)\r
59         * -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay\r
60         *      domain\r
61         *  0.5 AWL AWL: From: address is in the auto white-list\r
62 X-QM-Scan-Virus: ClamAV says the message is clean\r
63 X-BeenThere: notmuch@notmuchmail.org\r
64 X-Mailman-Version: 2.1.13\r
65 Precedence: list\r
66 List-Id: "Use and development of the notmuch mail system."\r
67         <notmuch.notmuchmail.org>\r
68 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
69         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
70 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
71 List-Post: <mailto:notmuch@notmuchmail.org>\r
72 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
73 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
74         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
75 X-List-Received-Date: Wed, 08 Aug 2012 21:23:46 -0000\r
76 \r
77 \r
78 The string function in a sprinter may be called with a NULL string\r
79 pointer (eg if a header is absent). This causes a segfault. We fix\r
80 this by checking for a null pointer in the string functions and update\r
81 the sprinter documentation.\r
82 \r
83 At the moment some output when format=text is done directly rather than\r
84 via an sprinter: in that case a null pointer is passed to printf or\r
85 similar and a "(null)" appears in the output. That behaviour is not\r
86 changed in this patch.\r
87 ---\r
88 \r
89 This is the same as id:"874noe1o0r.fsf@qmul.ac.uk" except for being\r
90 based on top of the test in the parent message, and marking the broken\r
91 test fixed.\r
92 \r
93 Best wishes\r
94 \r
95 Mark\r
96 \r
97  sprinter-json.c      |    2 ++\r
98  sprinter-text.c      |    2 ++\r
99  sprinter.h           |    4 +++-\r
100  test/missing-headers |    2 --\r
101  4 files changed, 7 insertions(+), 3 deletions(-)\r
102 \r
103 diff --git a/sprinter-json.c b/sprinter-json.c\r
104 index c9b6835..0a07790 100644\r
105 --- a/sprinter-json.c\r
106 +++ b/sprinter-json.c\r
107 @@ -118,6 +118,8 @@ json_string_len (struct sprinter *sp, const char *val, size_t len)\r
108  static void\r
109  json_string (struct sprinter *sp, const char *val)\r
110  {\r
111 +    if (val == NULL)\r
112 +       val = "";\r
113      json_string_len (sp, val, strlen (val));\r
114  }\r
115  \r
116 diff --git a/sprinter-text.c b/sprinter-text.c\r
117 index dfa54b5..10343be 100644\r
118 --- a/sprinter-text.c\r
119 +++ b/sprinter-text.c\r
120 @@ -38,6 +38,8 @@ text_string_len (struct sprinter *sp, const char *val, size_t len)\r
121  static void\r
122  text_string (struct sprinter *sp, const char *val)\r
123  {\r
124 +    if (val == NULL)\r
125 +       val = "";\r
126      text_string_len (sp, val, strlen (val));\r
127  }\r
128  \r
129 diff --git a/sprinter.h b/sprinter.h\r
130 index 5f43175..912a526 100644\r
131 --- a/sprinter.h\r
132 +++ b/sprinter.h\r
133 @@ -27,7 +27,9 @@ typedef struct sprinter {\r
134       * a list or map, followed or preceded by separators).  For string\r
135       * and string_len, the char * must be UTF-8 encoded.  string_len\r
136       * allows non-terminated strings and strings with embedded NULs\r
137 -     * (though the handling of the latter is format-dependent).\r
138 +     * (though the handling of the latter is format-dependent). For\r
139 +     * string (but not string_len) the string pointer passed may be\r
140 +     * NULL.\r
141       */\r
142      void (*string) (struct sprinter *, const char *);\r
143      void (*string_len) (struct sprinter *, const char *, size_t);\r
144 diff --git a/test/missing-headers b/test/missing-headers\r
145 index e79f922..f14b878 100755\r
146 --- a/test/missing-headers\r
147 +++ b/test/missing-headers\r
148 @@ -29,7 +29,6 @@ thread:XXX   2001-01-05 [1/1] (null);  (inbox unread)\r
149  thread:XXX   1970-01-01 [1/1] Notmuch Test Suite;  (inbox unread)"\r
150  \r
151  test_begin_subtest "Search: json"\r
152 -test_subtest_known_broken\r
153  output=$(notmuch search --format=json '*' | notmuch_search_sanitize)\r
154  test_expect_equal_json "$output" '\r
155  [\r
156 @@ -93,7 +92,6 @@ Body\r
157  \f\r
158 message}"\r
159  \r
160  test_begin_subtest "Show: json"\r
161 -test_subtest_known_broken\r
162  output=$(notmuch show --format=json '*' | notmuch_json_show_sanitize)\r
163  test_expect_equal_json "$output" '\r
164  [\r
165 -- \r
166 1.7.9.1\r
167 \r
168 \r