]> granicus.if.org Git - mutt/commitdiff
Fix imap_pretty_mailbox() call to url_ciss_tostring().
authorKevin McCarthy <kevin@8t8.us>
Sun, 10 Mar 2019 12:05:12 +0000 (20:05 +0800)
committerKevin McCarthy <kevin@8t8.us>
Mon, 11 Mar 2019 02:24:22 +0000 (10:24 +0800)
Pass the correct buffer size through, so the strfcpy added in the next
commit doesn't write past the end of the buffer.

imap/imap.h
imap/util.c
muttlib.c

index c5eb2aec3d6bdb5b38828c9894efe26aca1e6737..e1878d18a88162cc43d38fce5394d2c4d37ab719 100644 (file)
@@ -64,7 +64,7 @@ void imap_logout_all (void);
 /* util.c */
 int imap_expand_path (char* path, size_t len);
 int imap_parse_path (const char* path, IMAP_MBOX* mx);
-void imap_pretty_mailbox (char* path);
+void imap_pretty_mailbox (char* path, size_t pathlen);
 
 int imap_wait_keepalive (pid_t pid);
 void imap_keepalive (void);
index a1977216a17584fdad89722e686f27cffd15c577..fe0ed09dd7e8a73c9bc7b86c1b88f3dff96745f9 100644 (file)
@@ -406,7 +406,7 @@ int imap_mxcmp (const char* mx1, const char* mx2)
 
 /* imap_pretty_mailbox: called by mutt_pretty_mailbox to make IMAP paths
  *   look nice. */
-void imap_pretty_mailbox (char* path)
+void imap_pretty_mailbox (char* path, size_t pathlen)
 {
   IMAP_MBOX home, target;
   ciss_url_t url;
@@ -450,10 +450,7 @@ void imap_pretty_mailbox (char* path)
   {
     mutt_account_tourl (&target.account, &url);
     url.path = target.mbox;
-    /* FIXME: That hard-coded constant is bogus. But we need the actual
-     *   size of the buffer from mutt_pretty_mailbox. And these pretty
-     *   operations usually shrink the result. Still... */
-    url_ciss_tostring (&url, path, 1024, 0);
+    url_ciss_tostring (&url, path, pathlen, 0);
   }
 
   FREE (&target.mbox);
index 00560ed9db1999d1dd29d2cfec49ed135cd8b984..9ae4af9309ab0203c1b3991ff7de5959dbc2c542 100644 (file)
--- a/muttlib.c
+++ b/muttlib.c
@@ -914,7 +914,7 @@ void mutt_pretty_mailbox (char *s, size_t buflen)
 #ifdef USE_IMAP
   if (scheme == U_IMAP || scheme == U_IMAPS)
   {
-    imap_pretty_mailbox (s);
+    imap_pretty_mailbox (s, buflen);
     return;
   }
 #endif