Re: [PATCH] emacs: wash: make word-wrap bound message width
[notmuch-archives.git] / 66 / 1f7a5dcabd890852b34ef48337f9c38454c418
1 Return-Path: <novalazy@gmail.com>\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 94D45431FAF\r
6         for <notmuch@notmuchmail.org>; Sat, 24 Nov 2012 17:17:56 -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.799\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5\r
12         tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
13         FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] 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 9FVrlOmsE62o for <notmuch@notmuchmail.org>;\r
17         Sat, 24 Nov 2012 17:17:56 -0800 (PST)\r
18 Received: from mail-da0-f53.google.com (mail-da0-f53.google.com\r
19         [209.85.210.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
20         (No client certificate requested)\r
21         by olra.theworths.org (Postfix) with ESMTPS id 247F7431FAE\r
22         for <notmuch@notmuchmail.org>; Sat, 24 Nov 2012 17:17:56 -0800 (PST)\r
23 Received: by mail-da0-f53.google.com with SMTP id x6so2305796dac.26\r
24         for <notmuch@notmuchmail.org>; Sat, 24 Nov 2012 17:17:55 -0800 (PST)\r
25 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
26         h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references;\r
27         bh=xIoOTrPF204aON5fO76DkSt406Ccng0pbsk1vL/X2cw=;\r
28         b=QVmIN+7jCR/Gr35rlvVb6ymIIP8wEi3CCDEQv/rPcGbQTdw+Pcce5jMed2gMo3eb/w\r
29         iUXnK+3Mnjb9PxVxqbsJxBnJBJ9xUu21rhdIMjKZrPiyffC4Yw0bT2B8ECrdSkglWpDi\r
30         b5dGg2GnKPA+pX2J2zwREx6otNozxvg4tT/FkBmNPLWRr4o22bsfjvwQ2U8B4ZOanAEy\r
31         pBkSwe8YLHXFqxDrmc2ioVng+YgOVHi6zOkIAyuaE0OIhVRpjrSdTKNlT08NQi6VSkWV\r
32         eCsiqOm+a27wHDJ8UB12CM28BIKiPA0v9AOfPHk6gZqF5fJ6+zN4wab2UMcBAaalRcDv\r
33         eAfA==\r
34 Received: by 10.69.0.40 with SMTP id av8mr26370390pbd.117.1353806275387;\r
35         Sat, 24 Nov 2012 17:17:55 -0800 (PST)\r
36 Received: from localhost (215.42.233.220.static.exetel.com.au.\r
37         [220.233.42.215])\r
38         by mx.google.com with ESMTPS id i10sm6169840paz.17.2012.11.24.17.17.52\r
39         (version=TLSv1/SSLv3 cipher=OTHER);\r
40         Sat, 24 Nov 2012 17:17:54 -0800 (PST)\r
41 From: Peter Wang <novalazy@gmail.com>\r
42 To: notmuch@notmuchmail.org\r
43 Subject: [PATCH v2 09/20] insert: prevent writes outside Maildir hierarchy\r
44 Date: Sun, 25 Nov 2012 12:16:35 +1100\r
45 Message-Id: <1353806206-29133-10-git-send-email-novalazy@gmail.com>\r
46 X-Mailer: git-send-email 1.7.12.1\r
47 In-Reply-To: <1353806206-29133-1-git-send-email-novalazy@gmail.com>\r
48 References: <1353806206-29133-1-git-send-email-novalazy@gmail.com>\r
49 X-BeenThere: notmuch@notmuchmail.org\r
50 X-Mailman-Version: 2.1.13\r
51 Precedence: list\r
52 List-Id: "Use and development of the notmuch mail system."\r
53         <notmuch.notmuchmail.org>\r
54 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
55         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
56 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
57 List-Post: <mailto:notmuch@notmuchmail.org>\r
58 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
59 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
60         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
61 X-List-Received-Date: Sun, 25 Nov 2012 01:17:56 -0000\r
62 \r
63 Don't accept a --folder name that contains a ".." component,\r
64 in order to prevent writing outside of the Maildir hierarchy.\r
65 ---\r
66  notmuch-insert.c | 21 +++++++++++++++++++++\r
67  1 file changed, 21 insertions(+)\r
68 \r
69 diff --git a/notmuch-insert.c b/notmuch-insert.c\r
70 index a50eacc..022f7cd 100644\r
71 --- a/notmuch-insert.c\r
72 +++ b/notmuch-insert.c\r
73 @@ -38,6 +38,23 @@ safe_gethostname (char *hostname, size_t len)\r
74      return (strchr (hostname, '/') == NULL);\r
75  }\r
76  \r
77 +/* Check the specified folder name does not contain a directory\r
78 + * component ".." to prevent writes outside of the Maildir hierarchy. */\r
79 +static notmuch_bool_t\r
80 +check_folder_name (const char *folder)\r
81 +{\r
82 +    const char *p = folder;\r
83 +\r
84 +    for (;;) {\r
85 +       if ((p[0] == '.') && (p[1] == '.') && (p[2] == '\0' || p[2] == '/'))\r
86 +           return FALSE;\r
87 +       p = strchr (p, '/');\r
88 +       if (!p)\r
89 +           return TRUE;\r
90 +       p++;\r
91 +    }\r
92 +}\r
93 +\r
94  /* Open a unique file in the Maildir 'tmp' directory.\r
95   * Returns the file descriptor on success, or -1 on failure.\r
96   * On success, file paths into the 'tmp' and 'new' directories are returned\r
97 @@ -255,6 +272,10 @@ notmuch_insert_command (void *ctx, int argc, char *argv[])\r
98      db_path = notmuch_config_get_database_path (config);\r
99  \r
100      if (folder != NULL) {\r
101 +       if (! check_folder_name (folder)) {\r
102 +           fprintf (stderr, "Error: bad folder name: %s\n", folder);\r
103 +           return 1;\r
104 +       }\r
105         maildir = talloc_asprintf (ctx, "%s/%s", db_path, folder);\r
106      } else {\r
107         maildir = talloc_asprintf (ctx, "%s", db_path);\r
108 -- \r
109 1.7.12.1\r
110 \r