From: Richard Russon Date: Tue, 29 May 2018 15:52:55 +0000 (+0100) Subject: Enlarge buffers from LONG_STRING to PATH_MAX X-Git-Tag: neomutt-20180622~25^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=refs%2Fpull%2F1229%2Fhead;p=neomutt Enlarge buffers from LONG_STRING to PATH_MAX Every buffer that has a filesystem path copied into it --- diff --git a/bcache.c b/bcache.c index fde35e363..6e0b505fd 100644 --- a/bcache.c +++ b/bcache.c @@ -149,7 +149,7 @@ FILE *mutt_bcache_get(struct BodyCache *bcache, const char *id) FILE *mutt_bcache_put(struct BodyCache *bcache, const char *id) { - char path[LONG_STRING]; + char path[PATH_MAX]; struct stat sb; if (!id || !*id || !bcache) diff --git a/browser.c b/browser.c index 261e4b378..2357b9c78 100644 --- a/browser.c +++ b/browser.c @@ -895,7 +895,7 @@ static int examine_mailboxes(struct Menu *menu, struct BrowserState *state) tmp->msg_unread = Context->unread; } - char buffer[LONG_STRING]; + char buffer[PATH_MAX]; mutt_str_strfcpy(buffer, tmp->path, sizeof(buffer)); if (BrowserAbbreviateMailboxes) mutt_pretty_mailbox(buffer, sizeof(buffer)); @@ -930,7 +930,7 @@ static int examine_mailboxes(struct Menu *menu, struct BrowserState *state) if (mx_is_maildir(tmp->path)) { struct stat st2; - char md[LONG_STRING]; + char md[PATH_MAX]; snprintf(md, sizeof(md), "%s/new", tmp->path); if (stat(md, &s) < 0) diff --git a/buffy.c b/buffy.c index 5bc65d65f..d60f3149a 100644 --- a/buffy.c +++ b/buffy.c @@ -206,8 +206,8 @@ static void buffy_free(struct Buffy **mailbox) static int buffy_maildir_check_dir(struct Buffy *mailbox, const char *dir_name, bool check_new, bool check_stats) { - char path[LONG_STRING]; - char msgpath[LONG_STRING]; + char path[PATH_MAX]; + char msgpath[PATH_MAX]; DIR *dirp = NULL; struct dirent *de = NULL; char *p = NULL; diff --git a/complete.c b/complete.c index e6d64854c..7cfd1d518 100644 --- a/complete.c +++ b/complete.c @@ -65,7 +65,7 @@ int mutt_complete(char *buf, size_t buflen) char dirpart[PATH_MAX], exp_dirpart[PATH_MAX]; char filepart[PATH_MAX]; #ifdef USE_IMAP - char imap_path[LONG_STRING]; + char imap_path[PATH_MAX]; #endif mutt_debug(2, "completing %s\n", buf); diff --git a/imap/browse.c b/imap/browse.c index 071d6b747..f0c200abb 100644 --- a/imap/browse.c +++ b/imap/browse.c @@ -59,8 +59,8 @@ static void add_folder(char delim, char *folder, int noselect, int noinferiors, struct BrowserState *state, short isparent) { - char tmp[LONG_STRING]; - char relpath[LONG_STRING]; + char tmp[PATH_MAX]; + char relpath[PATH_MAX]; struct ImapMbox mx; struct Buffy *b = NULL; @@ -192,9 +192,9 @@ int imap_browse(char *path, struct BrowserState *state) { struct ImapData *idata = NULL; struct ImapList list; - char buf[LONG_STRING]; - char mbox[LONG_STRING]; - char munged_mbox[LONG_STRING]; + char buf[PATH_MAX]; + char mbox[PATH_MAX]; + char munged_mbox[PATH_MAX]; char list_cmd[5]; int n; char ctmp; @@ -364,7 +364,7 @@ int imap_mailbox_create(const char *folder) { struct ImapData *idata = NULL; struct ImapMbox mx; - char buf[LONG_STRING]; + char buf[PATH_MAX]; short n; if (imap_parse_path(folder, &mx) < 0) @@ -425,8 +425,8 @@ int imap_mailbox_rename(const char *mailbox) { struct ImapData *idata = NULL; struct ImapMbox mx; - char buf[LONG_STRING]; - char newname[SHORT_STRING]; + char buf[PATH_MAX]; + char newname[PATH_MAX]; if (imap_parse_path(mailbox, &mx) < 0) { diff --git a/imap/imap.c b/imap/imap.c index 5c735fd3a..e3ec4b30b 100644 --- a/imap/imap.c +++ b/imap/imap.c @@ -710,7 +710,7 @@ int imap_rename_mailbox(struct ImapData *idata, struct ImapMbox *mx, const char */ int imap_delete_mailbox(struct Context *ctx, struct ImapMbox *mx) { - char buf[LONG_STRING], mbox[LONG_STRING]; + char buf[PATH_MAX], mbox[PATH_MAX]; struct ImapData *idata = NULL; if (!ctx || !ctx->data) @@ -1981,8 +1981,8 @@ static int imap_mbox_open(struct Context *ctx) { struct ImapData *idata = NULL; struct ImapStatus *status = NULL; - char buf[LONG_STRING]; - char bufout[LONG_STRING]; + char buf[PATH_MAX]; + char bufout[PATH_MAX]; int count = 0; struct ImapMbox mx, pmx; int rc; @@ -2205,8 +2205,7 @@ fail_noidata: static int imap_mbox_open_append(struct Context *ctx, int flags) { struct ImapData *idata = NULL; - char buf[LONG_STRING]; - char mailbox[LONG_STRING]; + char mailbox[PATH_MAX]; struct ImapMbox mx; int rc; @@ -2237,6 +2236,7 @@ static int imap_mbox_open_append(struct Context *ctx, int flags) if (rc == -1) return -1; + char buf[PATH_MAX + 64]; snprintf(buf, sizeof(buf), _("Create %s?"), mailbox); if (Confirmcreate && mutt_yesorno(buf, 1) != MUTT_YES) return -1; diff --git a/imap/message.c b/imap/message.c index 9944040d3..efa1094d7 100644 --- a/imap/message.c +++ b/imap/message.c @@ -1367,9 +1367,9 @@ fail: int imap_copy_messages(struct Context *ctx, struct Header *h, char *dest, int delete) { struct Buffer cmd, sync_cmd; - char mbox[LONG_STRING]; - char mmbox[LONG_STRING]; - char prompt[LONG_STRING]; + char mbox[PATH_MAX]; + char mmbox[PATH_MAX]; + char prompt[PATH_MAX + 64]; int rc; struct ImapMbox mx; int err_continue = MUTT_NO; diff --git a/imap/util.c b/imap/util.c index 16cdc9623..23e4f7093 100644 --- a/imap/util.c +++ b/imap/util.c @@ -231,8 +231,8 @@ header_cache_t *imap_hcache_open(struct ImapData *idata, const char *path) { struct ImapMbox mx; struct Url url; - char cachepath[LONG_STRING]; - char mbox[LONG_STRING]; + char cachepath[PATH_MAX]; + char mbox[PATH_MAX]; if (path) imap_cachepath(idata, path, mbox, sizeof(mbox)); diff --git a/mbox.c b/mbox.c index a97c8c51c..68cc7946c 100644 --- a/mbox.c +++ b/mbox.c @@ -984,7 +984,7 @@ static int mbox_mbox_sync(struct Context *ctx, int *index_hint) struct MUpdate *old_offset = NULL; FILE *fp = NULL; struct Progress progress; - char msgbuf[STRING]; + char msgbuf[PATH_MAX + 64]; struct Buffy *tmp = NULL; /* sort message by their position in the mailbox on disk */ diff --git a/mh.c b/mh.c index f3c414e10..67276d981 100644 --- a/mh.c +++ b/mh.c @@ -2333,7 +2333,7 @@ static int mh_mbox_sync(struct Context *ctx, int *index_hint) #ifdef USE_HCACHE header_cache_t *hc = NULL; #endif /* USE_HCACHE */ - char msgbuf[STRING]; + char msgbuf[PATH_MAX + 64]; struct Progress progress; if (ctx->magic == MUTT_MH) @@ -2454,7 +2454,7 @@ static FILE *md_open_find_message(const char *folder, const char *unique, { char dir[PATH_MAX]; char tunique[PATH_MAX]; - char fname[LONG_STRING]; + char fname[PATH_MAX]; struct dirent *de = NULL; diff --git a/mutt/file.c b/mutt/file.c index 608a3d422..52199b509 100644 --- a/mutt/file.c +++ b/mutt/file.c @@ -423,7 +423,7 @@ int mutt_file_safe_rename(const char *src, const char *target) int mutt_file_rmtree(const char *path) { struct dirent *de = NULL; - char cur[LONG_STRING]; + char cur[PATH_MAX]; struct stat statbuf; int rc = 0; diff --git a/mutt_notmuch.c b/mutt_notmuch.c index 4337b0184..c4482b9fb 100644 --- a/mutt_notmuch.c +++ b/mutt_notmuch.c @@ -1942,7 +1942,7 @@ char *nm_uri_from_query(struct Context *ctx, char *buf, size_t buflen) bool nm_normalize_uri(char *new_uri, const char *orig_uri, size_t new_uri_sz) { mutt_debug(2, "(%s)\n", orig_uri); - char buf[LONG_STRING]; + char buf[PATH_MAX]; int rc = -1; struct Context tmp_ctx; @@ -2629,7 +2629,7 @@ static int nm_mbox_sync(struct Context *ctx, int *index_hint) if (!ctx->quiet) { /* all is in this function so we don't use data->progress here */ - char msgbuf[STRING]; + char msgbuf[PATH_MAX + 64]; snprintf(msgbuf, sizeof(msgbuf), _("Writing %s..."), ctx->path); mutt_progress_init(&progress, msgbuf, MUTT_PROGRESS_MSG, WriteInc, ctx->msgcount); } diff --git a/muttlib.c b/muttlib.c index 6aa492af2..86c7cb3fb 100644 --- a/muttlib.c +++ b/muttlib.c @@ -571,7 +571,7 @@ void mutt_pretty_mailbox(char *s, size_t buflen) void mutt_expand_file_fmt(char *dest, size_t destlen, const char *fmt, const char *src) { - char tmp[LONG_STRING]; + char tmp[PATH_MAX]; mutt_file_quote_filename(tmp, sizeof(tmp), src); mutt_expand_fmt(dest, destlen, fmt, tmp); diff --git a/mx.c b/mx.c index f9ba6051a..33a8a8297 100644 --- a/mx.c +++ b/mx.c @@ -691,7 +691,7 @@ int mx_mbox_close(struct Context *ctx, int *index_hint) int i, move_messages = 0, purge = 1, read_msgs = 0; struct Context f; char mbox[PATH_MAX]; - char buf[SHORT_STRING]; + char buf[PATH_MAX + 64]; if (!ctx) return 0; diff --git a/ncrypt/pgpinvoke.c b/ncrypt/pgpinvoke.c index e2f7ba1aa..be82fdf74 100644 --- a/ncrypt/pgpinvoke.c +++ b/ncrypt/pgpinvoke.c @@ -267,7 +267,7 @@ void pgp_invoke_import(const char *fname) void pgp_invoke_getkeys(struct Address *addr) { - char buf[LONG_STRING]; + char buf[PATH_MAX]; char tmp[LONG_STRING]; char cmd[HUGE_STRING]; int devnull; diff --git a/ncrypt/smime.c b/ncrypt/smime.c index 67a704fad..16d5c70f2 100644 --- a/ncrypt/smime.c +++ b/ncrypt/smime.c @@ -1379,7 +1379,7 @@ static pid_t smime_invoke_sign(FILE **smimein, FILE **smimeout, FILE **smimeerr, struct Body *smime_build_smime_entity(struct Body *a, char *certlist) { - char buf[LONG_STRING], certfile[LONG_STRING]; + char buf[LONG_STRING], certfile[PATH_MAX]; char tempfile[PATH_MAX], smimeerrfile[PATH_MAX]; char smimeinfile[PATH_MAX]; char *cert_start, *cert_end; diff --git a/pop.c b/pop.c index 5e5eedbe3..1da297252 100644 --- a/pop.c +++ b/pop.c @@ -460,7 +460,7 @@ static int pop_fetch_headers(struct Context *ctx) */ static int pop_open_mailbox(struct Context *ctx) { - char buf[LONG_STRING]; + char buf[PATH_MAX]; struct Connection *conn = NULL; struct Account acct; struct PopData *pop_data = NULL; diff --git a/recvattach.c b/recvattach.c index 0243cf353..5897f7b60 100644 --- a/recvattach.c +++ b/recvattach.c @@ -633,7 +633,7 @@ static void query_pipe_attachment(char *command, FILE *fp, struct Body *body, bo if (filter) { - char warning[STRING + PATH_MAX]; + char warning[PATH_MAX + STRING]; snprintf(warning, sizeof(warning), _("WARNING! You are about to overwrite %s, continue?"), body->filename); if (mutt_yesorno(warning, MUTT_NO) != MUTT_YES) diff --git a/sendlib.c b/sendlib.c index 154613f8e..9a8958765 100644 --- a/sendlib.c +++ b/sendlib.c @@ -988,7 +988,7 @@ int mutt_lookup_mime_type(struct Body *att, const char *path) { FILE *f = NULL; char *p = NULL, *q = NULL, *ct = NULL; - char buf[LONG_STRING]; + char buf[PATH_MAX]; char subtype[STRING], xtype[STRING]; int szf, sze, cur_sze; int type;