]> granicus.if.org Git - neomutt/commitdiff
Add type field for IMAP command data structure, check it before use.
authorBrendan Cully <brendan@kublai.com>
Thu, 10 Aug 2006 20:20:27 +0000 (20:20 +0000)
committerBrendan Cully <brendan@kublai.com>
Thu, 10 Aug 2006 20:20:27 +0000 (20:20 +0000)
imap/browse.c
imap/command.c
imap/imap.c
imap/imap_private.h

index 43463baf3504595af0b8f1926d9f1757efb19f05..75355022e6dc02bbfbbec93cd595674072d7279b 100644 (file)
@@ -112,6 +112,7 @@ int imap_browse (char* path, struct browser_state* state)
     {
       snprintf (buf, sizeof (buf), "%s \"\" \"%s\"", list_cmd, mbox);
       imap_cmd_start (idata, buf);
+      idata->cmdtype = IMAP_CT_LIST;
       idata->cmddata = &list;
       do
       {
@@ -371,6 +372,7 @@ static int browse_add_list_result (IMAP_DATA* idata, const char* cmd,
   }
 
   imap_cmd_start (idata, cmd);
+  idata->cmdtype = IMAP_CT_LIST;
   idata->cmddata = &list;
   do
   {
@@ -592,6 +594,7 @@ static int browse_verify_namespace (IMAP_DATA* idata,
                option (OPTIMAPLSUB) ? "LSUB" : "LIST", nsi->prefix);
 
     imap_cmd_start (idata, buf);
+    idata->cmdtype = IMAP_CT_LIST;
     idata->cmddata = &list;
     nsi->listable = 0;
     nsi->home_namespace = 0;
index 69d16445981b642b75700fe26955606cfe59cea6..c6fb63e230556a30c42da77efe02fd9db185d300 100644 (file)
@@ -607,7 +607,7 @@ static void cmd_parse_list (IMAP_DATA* idata, char* s)
   char delimbuf[5]; /* worst case: "\\"\0 */
   long litlen;
 
-  if (idata->cmddata)
+  if (idata->cmddata && idata->cmdtype == IMAP_CT_LIST)
     list = (IMAP_LIST*)idata->cmddata;
   else
     list = &lb;
@@ -679,7 +679,7 @@ static void cmd_parse_lsub (IMAP_DATA* idata, char* s)
   ciss_url_t url;
   IMAP_LIST list;
 
-  if (idata->cmddata)
+  if (idata->cmddata && idata->cmdtype == IMAP_CT_LIST)
   {
     /* caller will handle response itself */
     cmd_parse_list (idata, s);
@@ -851,7 +851,7 @@ static void cmd_parse_status (IMAP_DATA* idata, char* s)
               status->messages, status->recent, status->unseen));
 
   /* caller is prepared to handle the result herself */
-  if (idata->cmddata)
+  if (idata->cmddata && idata->cmdtype == IMAP_CT_STATUS)
   {
     memcpy (idata->cmddata, status, sizeof (IMAP_STATUS));
     return;
index 8688a21b4fc75d6de886ada1c14125282bc50977..cbec5cbfcc852b596e3408fc2e7a68b455c2bcb2 100644 (file)
@@ -1892,6 +1892,7 @@ int imap_complete(char* dest, size_t dlen, char* path) {
 
   /* and see what the results are */
   strfcpy (completion, NONULL(mx.mbox), sizeof(completion));
+  idata->cmdtype = IMAP_CT_LIST;
   idata->cmddata = &listresp;
   do
   {
index ac97deaffee06c717e795b35bc5c5e2f181d3918..ecae3c346c53d1c9cd7fe27aa51fd90672cf999a 100644 (file)
@@ -180,6 +180,13 @@ typedef struct
   int state;
 } IMAP_COMMAND;
 
+typedef enum
+{
+  IMAP_CT_NONE = 0,
+  IMAP_CT_LIST,
+  IMAP_CT_STATUS
+} IMAP_COMMAND_TYPE;
+
 typedef struct
 {
   /* This data is specific to a CONNECTION to an IMAP server */
@@ -200,8 +207,11 @@ typedef struct
   time_t lastread; /* last time we read a command for the server */
   char* buf;
   unsigned int blen;
-  void* cmddata; /* if set, the response parser will store results for
-                  * complicated commands here. */
+  
+  /* if set, the response parser will store results for complicated commands
+   * here. */
+  IMAP_COMMAND_TYPE cmdtype;
+  void* cmddata;
 
   /* command queue */
   IMAP_COMMAND cmds[IMAP_PIPELINE_DEPTH];