the position of hotmail's UID is at the end of BODYSTRUCTURE 41/91541/5
authorSan Cho <san.cho@samsung.com>
Fri, 20 May 2016 09:00:17 +0000 (18:00 +0900)
committerintae jeon <intae.jeon@samsung.com>
Mon, 24 Oct 2016 06:03:50 +0000 (23:03 -0700)
[Problem] the position of hotmail's UID is at the end of BODYSTRUCTURE
[Cause & Measure] Cause: the position of hotmail's UID is different from other email service provider, so index error occurred
Meause: Checking UID string pointer when parsing BODYSTRUCTURE

Change-Id: I9cc78af63a51cf422f2c655c8a0b0a6c3f7a4922

email-core/email-core-mailbox-sync.c

index 116c083..2a49313 100755 (executable)
@@ -3961,6 +3961,7 @@ static int emcore_gmime_download_imap_partial_mail_body(MAILSTREAM *stream, int
                if (!(imap_response[i].bodystructure) || imap_response[i].bodystructure_len <= 0) continue;
 
                /* Search the account id of pbd_event */
+               EM_DEBUG_LOG("Find server_mail_id: [%d]", imap_response[i].uid_no);
                for (temp_count = 0; temp_count < item_count && pbd_event[temp_count].server_mail_id != imap_response[i].uid_no; temp_count++)
                        continue;
 
@@ -4774,15 +4775,14 @@ static email_partial_buffer *emcore_get_response_from_server(NETSTREAM *nstream,
 
                        if (full_line) p_bodystructure = strcasestr(full_line, "BODYSTRUCTURE");
                        if (full_line) p_bodystructure_end = strcasestr(full_line, "BODY[TEXT]");
+                       if (full_line) p_uid = strcasestr(full_line, "UID");
 
                        /* check whether full header is received */
-                       if (p_bodystructure && p_bodystructure_end) {
+                       if (p_bodystructure && p_bodystructure_end && p_uid) {
 
                                /* get UID */
-                               if ((p_uid = strcasestr(full_line, "UID")) != NULL) {
-                                       p_uid = p_uid + strlen("UID ");
-                                       server_response[count].uid_no = atol(p_uid);
-                               }
+                               p_uid = p_uid + strlen("UID ");
+                               server_response[count].uid_no = atol(p_uid);
 
                                /* get BODYSTRUCTURE */
                                server_response[count].bodystructure_len = p_bodystructure_end - p_bodystructure;
@@ -4820,11 +4820,13 @@ static email_partial_buffer *emcore_get_response_from_server(NETSTREAM *nstream,
                                count++;
                                p_bodystructure = NULL;
                                p_bodystructure_end = NULL;
+                               p_uid = NULL;
                                continue;
                        } else {
                                /* not a full header, accumulate into buffer util get the end of header */
                                p_bodystructure = NULL;
                                p_bodystructure_end = NULL;
+                               p_uid = NULL;
                                continue;
                        }
                }