From: Kevin McCarthy Date: Fri, 28 Sep 2018 00:29:16 +0000 (-0700) Subject: Increase buffer sizes for some IMAP commands. X-Git-Tag: mutt-1-11-rel~60 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=51efb7261dc58124779de1a6c1088c6f35bfa78d;p=mutt Increase buffer sizes for some IMAP commands. Use to ensure assembled IMAP commands fit in the resultant buffer to be imap_exec()'ed. RFC2683 suggested a limit of 1000, but asked servers to accept up to 8000. Furthermore, RFC7162 bumped the client limit suggestion up to 8192. So I don't believe any issues will be caused by this. Most of these are increases are just to remove theoretical truncation warned about by the compiler; I don't believe we've had reports of actual command truncation due to a mailbox 1024 characters long. --- diff --git a/imap/browse.c b/imap/browse.c index acda9f94..aada493d 100644 --- a/imap/browse.c +++ b/imap/browse.c @@ -43,7 +43,7 @@ int imap_browse (char* path, struct browser_state* state) { IMAP_DATA* idata; IMAP_LIST list; - char buf[LONG_STRING]; + char buf[LONG_STRING*2]; char mbox[LONG_STRING]; char munged_mbox[LONG_STRING]; char list_cmd[5]; diff --git a/imap/imap.c b/imap/imap.c index bd7b310a..7104dbb1 100644 --- a/imap/imap.c +++ b/imap/imap.c @@ -59,7 +59,7 @@ int imap_access (const char* path) { IMAP_DATA* idata; IMAP_MBOX mx; - char buf[LONG_STRING]; + char buf[LONG_STRING*2]; char mailbox[LONG_STRING]; char mbox[LONG_STRING]; int rc; @@ -115,7 +115,7 @@ int imap_access (const char* path) int imap_create_mailbox (IMAP_DATA* idata, char* mailbox) { - char buf[LONG_STRING], mbox[LONG_STRING]; + char buf[LONG_STRING*2], mbox[LONG_STRING]; imap_munge_mbox_name (idata, mbox, sizeof (mbox), mailbox); snprintf (buf, sizeof (buf), "CREATE %s", mbox); @@ -133,7 +133,7 @@ int imap_rename_mailbox (IMAP_DATA* idata, IMAP_MBOX* mx, const char* newname) { char oldmbox[LONG_STRING]; char newmbox[LONG_STRING]; - char buf[LONG_STRING]; + char buf[HUGE_STRING]; imap_munge_mbox_name (idata, oldmbox, sizeof (oldmbox), mx->mbox); imap_munge_mbox_name (idata, newmbox, sizeof (newmbox), newname); @@ -148,7 +148,7 @@ int imap_rename_mailbox (IMAP_DATA* idata, IMAP_MBOX* mx, const char* newname) int imap_delete_mailbox (CONTEXT* ctx, IMAP_MBOX mx) { - char buf[LONG_STRING], mbox[LONG_STRING]; + char buf[LONG_STRING*2], mbox[LONG_STRING]; IMAP_DATA *idata; if (!ctx || !ctx->data) { @@ -606,7 +606,7 @@ static int imap_open_mailbox (CONTEXT* ctx) IMAP_DATA *idata; IMAP_STATUS* status; char buf[LONG_STRING]; - char bufout[LONG_STRING]; + char bufout[LONG_STRING*2]; int count = 0; IMAP_MBOX mx, pmx; int rc; @@ -1607,7 +1607,7 @@ int imap_buffy_check (int force, int check_stats) IMAP_DATA* lastdata = NULL; BUFFY* mailbox; char name[LONG_STRING]; - char command[LONG_STRING]; + char command[LONG_STRING*2]; char munged[LONG_STRING]; int buffies = 0; @@ -1698,7 +1698,7 @@ int imap_status (const char* path, int queue) static int queued = 0; IMAP_DATA *idata; - char buf[LONG_STRING]; + char buf[LONG_STRING*2]; char mbox[LONG_STRING]; IMAP_STATUS* status; @@ -1967,7 +1967,7 @@ int imap_search (CONTEXT* ctx, const pattern_t* pat) int imap_subscribe (char *path, int subscribe) { IMAP_DATA *idata; - char buf[LONG_STRING]; + char buf[LONG_STRING*2]; char mbox[LONG_STRING]; char errstr[STRING]; int mblen; @@ -2097,7 +2097,7 @@ imap_complete_hosts (char *dest, size_t len) int imap_complete(char* dest, size_t dlen, char* path) { IMAP_DATA* idata; char list[LONG_STRING]; - char buf[LONG_STRING]; + char buf[LONG_STRING*2]; IMAP_LIST listresp; char completion[LONG_STRING]; int clen; diff --git a/imap/message.c b/imap/message.c index 19bad85f..fc326752 100644 --- a/imap/message.c +++ b/imap/message.c @@ -1089,7 +1089,7 @@ int imap_append_message (CONTEXT *ctx, MESSAGE *msg) { IMAP_DATA* idata; FILE *fp; - char buf[LONG_STRING]; + char buf[LONG_STRING*2]; char mbox[LONG_STRING]; char mailbox[LONG_STRING]; char internaldate[IMAP_DATELEN]; diff --git a/lib.h b/lib.h index 11638dfe..eec531b6 100644 --- a/lib.h +++ b/lib.h @@ -57,10 +57,10 @@ # define TRUE 1 # define FALSE 0 -# define HUGE_STRING 8192 -# define LONG_STRING 1024 -# define STRING 256 -# define SHORT_STRING 128 +# define HUGE_STRING 8192 +# define LONG_STRING 1024 +# define STRING 256 +# define SHORT_STRING 128 /* * Create a format string to be used with scanf.