[PATCH] notmuch-config: talloc_strdup MAILDIR and NAME environment variables
authorTomi Ollila <tomi.ollila@iki.fi>
Thu, 7 Aug 2014 15:19:50 +0000 (18:19 +0300)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 18:04:08 +0000 (10:04 -0800)
b9/01f89f79350adafe9d45fcad8ee4aa2befa86c [new file with mode: 0644]

diff --git a/b9/01f89f79350adafe9d45fcad8ee4aa2befa86c b/b9/01f89f79350adafe9d45fcad8ee4aa2befa86c
new file mode 100644 (file)
index 0000000..a7b9428
--- /dev/null
@@ -0,0 +1,78 @@
+Return-Path: <too@guru-group.fi>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id C9C9E431FAE\r
+       for <notmuch@notmuchmail.org>; Thu,  7 Aug 2014 08:20:22 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
+       autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id 29k-NnquOo3X for <notmuch@notmuchmail.org>;\r
+       Thu,  7 Aug 2014 08:20:18 -0700 (PDT)\r
+Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34])\r
+       by olra.theworths.org (Postfix) with ESMTP id D8CE9431FC2\r
+       for <notmuch@notmuchmail.org>; Thu,  7 Aug 2014 08:20:05 -0700 (PDT)\r
+Received: by guru.guru-group.fi (Postfix, from userid 501)\r
+       id D52BE1000E0; Thu,  7 Aug 2014 18:19:52 +0300 (EEST)\r
+From: Tomi Ollila <tomi.ollila@iki.fi>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH] notmuch-config: talloc_strdup MAILDIR and NAME environment\r
+       variables\r
+Date: Thu,  7 Aug 2014 18:19:50 +0300\r
+Message-Id: <1407424790-12538-1-git-send-email-tomi.ollila@iki.fi>\r
+X-Mailer: git-send-email 2.0.0\r
+Cc: tomi.ollila@iki.fi\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Thu, 07 Aug 2014 15:20:22 -0000\r
+\r
+When defined -- the pointer is soon given to talloc_free() which\r
+expects it to be allocated by talloc.\r
+---\r
+ notmuch-config.c | 8 ++++++--\r
+ 1 file changed, 6 insertions(+), 2 deletions(-)\r
+\r
+diff --git a/notmuch-config.c b/notmuch-config.c\r
+index 88831e2..db487db 100644\r
+--- a/notmuch-config.c\r
++++ b/notmuch-config.c\r
+@@ -324,7 +324,9 @@ notmuch_config_open (void *ctx,\r
\r
+     if (notmuch_config_get_database_path (config) == NULL) {\r
+       char *path = getenv ("MAILDIR");\r
+-      if (! path)\r
++      if (path)\r
++          path = talloc_strdup (config, path);\r
++      else\r
+           path = talloc_asprintf (config, "%s/mail",\r
+                                   getenv ("HOME"));\r
+       notmuch_config_set_database_path (config, path);\r
+@@ -333,7 +335,9 @@ notmuch_config_open (void *ctx,\r
\r
+     if (notmuch_config_get_user_name (config) == NULL) {\r
+       char *name = getenv ("NAME");\r
+-      if (! name)\r
++      if (name)\r
++          name = talloc_strdup (config, name);\r
++      else\r
+           name = get_name_from_passwd_file (config);\r
+       notmuch_config_set_user_name (config, name);\r
+       talloc_free (name);\r
+-- \r
+1.9.3\r
+\r