]> granicus.if.org Git - mutt/commitdiff
Increase buffer sizes for some IMAP commands.
authorKevin McCarthy <kevin@8t8.us>
Fri, 28 Sep 2018 00:29:16 +0000 (17:29 -0700)
committerKevin McCarthy <kevin@8t8.us>
Sun, 30 Sep 2018 22:42:41 +0000 (15:42 -0700)
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.

imap/browse.c
imap/imap.c
imap/message.c
lib.h

index acda9f94affb99c58f54e29218f8fd8ec17e2ee9..aada493d1714a82746f5a39c71cac4fb41b58219 100644 (file)
@@ -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];
index bd7b310a10b8b60fd743dd8510912053bbd204b9..7104dbb1209c14691a4b3e78f96760be7a42fcb0 100644 (file)
@@ -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;
index 19bad85f76c6faea6ae6fbabc6024550615feab2..fc326752c8e46e5005c9f56d5ffbd30e4144da0d 100644 (file)
@@ -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 11638dfe25a5df89beca56a2c0a3d80fd451d4ca..eec531b60afd07d90682a3d32c631ba8e7b61857 100644 (file)
--- a/lib.h
+++ b/lib.h
 # 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.