From: Kevin McCarthy Date: Sun, 10 Mar 2019 12:05:12 +0000 (+0800) Subject: Fix imap_pretty_mailbox() call to url_ciss_tostring(). X-Git-Tag: mutt-1-12-rel~97 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=716c02222b2f35fb7707f766bfd8630c92f898ce;p=mutt Fix imap_pretty_mailbox() call to url_ciss_tostring(). Pass the correct buffer size through, so the strfcpy added in the next commit doesn't write past the end of the buffer. --- diff --git a/imap/imap.h b/imap/imap.h index c5eb2aec..e1878d18 100644 --- a/imap/imap.h +++ b/imap/imap.h @@ -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); diff --git a/imap/util.c b/imap/util.c index a1977216..fe0ed09d 100644 --- a/imap/util.c +++ b/imap/util.c @@ -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); diff --git a/muttlib.c b/muttlib.c index 00560ed9..9ae4af93 100644 --- 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