]> granicus.if.org Git - mutt/commitdiff
Selectively cache headers.
authorRichard Russon <rich@flatcap.org>
Fri, 13 Jul 2018 18:33:16 +0000 (11:33 -0700)
committerKevin McCarthy <kevin@8t8.us>
Fri, 13 Jul 2018 18:33:16 +0000 (11:33 -0700)
Thanks to NeoMutt and Jeriko One for the patch, which was slightly
modified to apply to the Mutt code.

imap/util.c

index 2779294454358a1969f3696c9f1dd030b0100c0b..d4cc274258ac878e67ce2fb1b79445aee9de9bd9 100644 (file)
@@ -84,6 +84,7 @@ header_cache_t* imap_hcache_open (IMAP_DATA* idata, const char* path)
   ciss_url_t url;
   char cachepath[LONG_STRING];
   char mbox[LONG_STRING];
+  size_t len;
 
   if (path)
     imap_cachepath (idata, path, mbox, sizeof (mbox));
@@ -96,6 +97,12 @@ header_cache_t* imap_hcache_open (IMAP_DATA* idata, const char* path)
     FREE (&mx.mbox);
   }
 
+  if (strstr(mbox, "/../") || (strcmp(mbox, "..") == 0) || (strncmp(mbox, "../", 3) == 0))
+    return NULL;
+  len = strlen(mbox);
+  if ((len > 3) && (strcmp(mbox + len - 3, "/..") == 0))
+    return NULL;
+
   mutt_account_tourl (&idata->conn->account, &url);
   url.path = mbox;
   url_ciss_tostring (&url, cachepath, sizeof (cachepath), U_PATH);