]> granicus.if.org Git - neomutt/commitdiff
Prevent renaming root folder in imap.
authorKevin McCarthy <kevin@8t8.us>
Wed, 23 Mar 2016 22:28:25 +0000 (15:28 -0700)
committerKevin McCarthy <kevin@8t8.us>
Wed, 23 Mar 2016 22:28:25 +0000 (15:28 -0700)
The root folder results in mx.mbox being NULL, which causes a
segfault.  This can be triggered by entering a subfolder and trying to
rename the ".." entry.

Due to the translation string freeze, no visible error message is
displayed.  Add a TODO note about this for post-1.6 release.

imap/browse.c

index c3ea2f7144aaa026d9834d44f92f20bceff8884c..ccbf1c6fca2e740379fc6b068a8e9efb93cc2575 100644 (file)
@@ -319,8 +319,16 @@ int imap_mailbox_rename(const char* mailbox)
     goto fail;
   }
 
+  /* TODO: add mutt_error call, such as
+   * "Cannot rename root folder"
+   */
+  if (!mx.mbox)
+  {
+    goto fail;
+  }
+
   snprintf(buf, sizeof (buf), _("Rename mailbox %s to: "), mx.mbox);
-  strfcpy (newname, NONULL (mx.mbox), sizeof (newname));
+  strfcpy (newname, mx.mbox, sizeof (newname));
   
  if (mutt_get_field (buf, newname, sizeof (newname), M_FILE) < 0)
     goto fail;