Hi,

in case it helps anyone: Applying the upstream patch on top of the
current packaged version seems to work just fine – attached the debdiff
of my local MNU in case someone wants to be even lazier than me (modulo
just waiting for the next upload/falling back to mutt of course).

Note that I had to build with DEB_BUILD_OPTIONS=nocheck as 4 tests were
failing… (localtime related). Literally no idea why – it is the same
without the patch.


Best regards

David Kalnischkies
diff -Nru neomutt-20191102+dfsg.1/debian/changelog 
neomutt-20191102+dfsg.1/debian/changelog
--- neomutt-20191102+dfsg.1/debian/changelog    2019-11-03 00:21:21.000000000 
+0100
+++ neomutt-20191102+dfsg.1/debian/changelog    2019-11-07 21:46:47.000000000 
+0100
@@ -1,3 +1,11 @@
+neomutt (20191102+dfsg.1-1.1) UNRELEASED; urgency=medium
+
+  * Non-maintainer upload.
+  * Add upstream patch to fix startup crash in mutt_extract_token
+    (Closes: #944045)
+
+ -- David Kalnischkies <[email protected]>  Thu, 07 Nov 2019 21:46:47 +0100
+
 neomutt (20191102+dfsg.1-1) unstable; urgency=medium
 
   * New upstream release.
diff -Nru 
neomutt-20191102+dfsg.1/debian/patches/misc/fix-crash-in-mutt_extract_token.patch
 
neomutt-20191102+dfsg.1/debian/patches/misc/fix-crash-in-mutt_extract_token.patch
--- 
neomutt-20191102+dfsg.1/debian/patches/misc/fix-crash-in-mutt_extract_token.patch
   1970-01-01 01:00:00.000000000 +0100
+++ 
neomutt-20191102+dfsg.1/debian/patches/misc/fix-crash-in-mutt_extract_token.patch
   2019-11-07 21:46:47.000000000 +0100
@@ -0,0 +1,69 @@
+From: Richard Russon <[email protected]>
+Subject: fix crash in mutt_extract_token()
+
+The first attempt to fix the crash in mutt_extract_token() just moved
+the problem.  This refactors the code to simplify the shuffling of
+strings.
+
+Origin: upstream, 
https://github.com/neomutt/neomutt/commit/b486e37c1d5b5ea1b426f844a01c39c2827832dc
+Bug: https://github.com/neomutt/neomutt/issues/1921
+Bug-Debian: https://bugs.debian.org/944045
+
+--- a/init.c
++++ b/init.c
+@@ -2735,9 +2735,6 @@
+     {
+       FILE *fp = NULL;
+       pid_t pid;
+-      char *ptr = NULL;
+-      size_t expnlen;
+-      struct Buffer expn;
+       int line = 0;
+ 
+       pc = tok->dptr;
+@@ -2783,7 +2780,7 @@
+       tok->dptr = pc + 1;
+ 
+       /* read line */
+-      mutt_buffer_init(&expn);
++      struct Buffer expn = mutt_buffer_make(0);
+       expn.data = mutt_file_read_line(NULL, &expn.dsize, fp, &line, 0);
+       mutt_file_fclose(&fp);
+       mutt_wait_filter(pid);
+@@ -2792,21 +2789,22 @@
+        * plus whatever else was left on the original line */
+       /* BUT: If this is inside a quoted string, directly add output to
+        * the token */
+-      if (expn.data && qc)
++      if (expn.data)
+       {
+-        mutt_buffer_addstr(dest, expn.data);
+-        FREE(&expn.data);
+-      }
+-      else if (expn.data)
+-      {
+-        expnlen = mutt_str_strlen(expn.data);
+-        tok->dsize = expnlen + mutt_str_strlen(tok->dptr) + 1;
+-        ptr = mutt_mem_malloc(tok->dsize);
+-        memcpy(ptr, expn.data, expnlen);
+-        strcpy(ptr + expnlen, tok->dptr);
+-        mutt_buffer_strcpy(tok, ptr);
+-        tok->dptr = tok->data;
+-        FREE(&ptr);
++        if (qc)
++        {
++          mutt_buffer_addstr(dest, expn.data);
++        }
++        else
++        {
++          struct Buffer *copy = mutt_buffer_pool_get();
++          mutt_buffer_fix_dptr(&expn);
++          mutt_buffer_copy(copy, &expn);
++          mutt_buffer_addstr(copy, tok->dptr);
++          mutt_buffer_copy(tok, copy);
++          tok->dptr = tok->data;
++          mutt_buffer_pool_release(&copy);
++        }
+         FREE(&expn.data);
+       }
+     }
diff -Nru neomutt-20191102+dfsg.1/debian/patches/series 
neomutt-20191102+dfsg.1/debian/patches/series
--- neomutt-20191102+dfsg.1/debian/patches/series       2018-03-24 
09:39:34.000000000 +0100
+++ neomutt-20191102+dfsg.1/debian/patches/series       2019-11-07 
21:43:24.000000000 +0100
@@ -2,3 +2,4 @@
 debian-specific/use_usr_bin_editor.patch
 debian-specific/document_debian_defaults.patch
 misc/smime.rc.patch
+misc/fix-crash-in-mutt_extract_token.patch

Attachment: signature.asc
Description: PGP signature

Reply via email to