unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH] CLI/restore: handle missing keys and values in config data.
@ 2018-01-07 21:30 David Bremner
  2018-01-07 23:10 ` Daniel Kahn Gillmor
  0 siblings, 1 reply; 8+ messages in thread
From: David Bremner @ 2018-01-07 21:30 UTC (permalink / raw)
  To: notmuch

jrollins discovered that

   % echo '@#foo' | notmuch restore

currently segfaults.

Although such lines can't occur in notmuch dump output, they might be
useful for clearing config, and anyway segfaulting is not the best
error message.
---
 notmuch-restore.c | 8 ++++++++
 1 file changed, 8 insertions(+)

This should probably add a couple of tests. And maybe the commit
message should mention handling null keys.

diff --git a/notmuch-restore.c b/notmuch-restore.c
index dee19c20..3d36fc55 100644
--- a/notmuch-restore.c
+++ b/notmuch-restore.c
@@ -36,7 +36,15 @@ process_config_line (notmuch_database_t *notmuch, const char* line)
     void *local = talloc_new(NULL);
 
     key_p = strtok_len_c (line, delim, &key_len);
+    if (!key_p) {
+	fprintf (stderr, "missing config key on line %s\n", line);
+	goto DONE;
+    }
+
     val_p = strtok_len_c (key_p+key_len, delim, &val_len);
+    if (!val_p) {
+	val_p = "";
+    }
 
     key = talloc_strndup (local, key_p, key_len);
     val = talloc_strndup (local, val_p, val_len);
-- 
2.15.1

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2018-04-30 11:11 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-07 21:30 [PATCH] CLI/restore: handle missing keys and values in config data David Bremner
2018-01-07 23:10 ` Daniel Kahn Gillmor
2018-01-08  0:12   ` David Bremner
2018-02-09 16:52     ` Daniel Kahn Gillmor
2018-02-15  5:53       ` Tomi Ollila
2018-02-18  5:05         ` Daniel Kahn Gillmor
2018-02-18 11:37       ` David Bremner
2018-04-30 11:11   ` David Bremner

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).