]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
imap: Added check for empty UID in FETCH command
authorSteve Holme <steve_holme@hotmail.com>
Wed, 6 Mar 2013 19:33:49 +0000 (19:33 +0000)
committerSteve Holme <steve_holme@hotmail.com>
Wed, 6 Mar 2013 19:33:49 +0000 (19:33 +0000)
As the UID has to be specified by the user for the FETCH command to work
correctly, added a check to imap_fetch(), although strictly speaking it
is protected by the call from imap_perform().

lib/imap.c

index 4a4f0a3c298e7372032f7ae126887234a9301406..c2f065acb1c5587b32a492d1ff9c0d9fd53e4e7b 100644 (file)
@@ -748,9 +748,15 @@ static CURLcode imap_fetch(struct connectdata *conn)
   CURLcode result = CURLE_OK;
   struct IMAP *imap = conn->data->state.proto.imap;
 
+  /* Check we have a UID */
+  if(!imap->uid) {
+    failf(conn->data, "Cannot FETCH without a UID.");
+    return CURLE_URL_MALFORMAT;
+  }
+
   /* Send the FETCH command */
   result = imap_sendf(conn, "FETCH %s BODY[%s]",
-                      imap->uid ? imap->uid : "1",
+                      imap->uid,
                       imap->section ? imap->section : "");
 
   if(!result)