-rw-r--r-- | libetpan/src/data-types/mailstream_helper.c | 11 | ||||
-rw-r--r-- | libetpan/src/driver/implementation/pop3/pop3driver.c | 8 | ||||
-rw-r--r-- | libetpan/src/low-level/imap/mailimap_parser.c | 22 | ||||
-rw-r--r-- | libetpan/src/low-level/maildir/maildir.c | 17 | ||||
-rw-r--r-- | libetpan/src/low-level/mh/mailmh.c | 3 | ||||
-rw-r--r-- | libetpan/src/low-level/pop3/mailpop3.c | 7 |
6 files changed, 59 insertions, 9 deletions
diff --git a/libetpan/src/data-types/mailstream_helper.c b/libetpan/src/data-types/mailstream_helper.c index 2f0b9ae..f0ddf51 100644 --- a/libetpan/src/data-types/mailstream_helper.c +++ b/libetpan/src/data-types/mailstream_helper.c | |||
@@ -98,8 +98,15 @@ char * mailstream_read_line_append(mailstream * stream, MMAPString * line) | |||
98 | if (r == -1) | 98 | if (r == -1) |
99 | return NULL; | 99 | return NULL; |
100 | 100 | ||
101 | if (r == 0) | 101 | if (r == 0) { |
102 | break; | 102 | // LR |
103 | // this avoids a memory access violation later when trying | ||
104 | // to remove_trailing_eol from a null string | ||
105 | if ( line->len == 0 ) | ||
106 | return NULL; | ||
107 | else | ||
108 | break; | ||
109 | } | ||
103 | } | 110 | } |
104 | } | 111 | } |
105 | while (1); | 112 | while (1); |
diff --git a/libetpan/src/driver/implementation/pop3/pop3driver.c b/libetpan/src/driver/implementation/pop3/pop3driver.c index ea69923..6cc6a9a 100644 --- a/libetpan/src/driver/implementation/pop3/pop3driver.c +++ b/libetpan/src/driver/implementation/pop3/pop3driver.c | |||
@@ -249,6 +249,8 @@ static int pop3driver_login(mailsession * session, | |||
249 | char * userid, char * password) | 249 | char * userid, char * password) |
250 | { | 250 | { |
251 | int r; | 251 | int r; |
252 | //LR | ||
253 | int ret; | ||
252 | carray * msg_tab; | 254 | carray * msg_tab; |
253 | struct pop3_session_state_data * data; | 255 | struct pop3_session_state_data * data; |
254 | 256 | ||
@@ -271,7 +273,11 @@ static int pop3driver_login(mailsession * session, | |||
271 | break; | 273 | break; |
272 | } | 274 | } |
273 | 275 | ||
274 | mailpop3_list(get_pop3_session(session), &msg_tab); | 276 | // LR 2 lines |
277 | ret = pop3driver_pop3_error_to_mail_error(r); | ||
278 | if ( ret == MAIL_NO_ERROR ) | ||
279 | mailpop3_list(get_pop3_session(session), &msg_tab); | ||
280 | // LR | ||
275 | 281 | ||
276 | return pop3driver_pop3_error_to_mail_error(r); | 282 | return pop3driver_pop3_error_to_mail_error(r); |
277 | } | 283 | } |
diff --git a/libetpan/src/low-level/imap/mailimap_parser.c b/libetpan/src/low-level/imap/mailimap_parser.c index ab4db67..071891c 100644 --- a/libetpan/src/low-level/imap/mailimap_parser.c +++ b/libetpan/src/low-level/imap/mailimap_parser.c | |||
@@ -2399,8 +2399,26 @@ mailimap_body_fld_enc_parse(mailstream * fd, MMAPString * buffer, | |||
2399 | r = mailimap_string_parse(fd, buffer, &cur_token, &value, NULL, | 2399 | r = mailimap_string_parse(fd, buffer, &cur_token, &value, NULL, |
2400 | progr_rate, progr_fun); | 2400 | progr_rate, progr_fun); |
2401 | if (r != MAILIMAP_NO_ERROR) { | 2401 | if (r != MAILIMAP_NO_ERROR) { |
2402 | res = r; | 2402 | // LR start |
2403 | goto err; | 2403 | // accept NIL and set type to utf8 |
2404 | int ret = r; | ||
2405 | r = mailimap_char_parse(fd, buffer, &cur_token, 'N'); | ||
2406 | if (r == MAILIMAP_NO_ERROR) { | ||
2407 | r = mailimap_char_parse(fd, buffer, &cur_token, 'I'); | ||
2408 | if (r == MAILIMAP_NO_ERROR) { | ||
2409 | r = mailimap_char_parse(fd, buffer, &cur_token, 'L'); | ||
2410 | if (r == MAILIMAP_NO_ERROR) { | ||
2411 | type = 4; | ||
2412 | ret = MAILIMAP_NO_ERROR; | ||
2413 | value = NULL; | ||
2414 | } | ||
2415 | } | ||
2416 | } | ||
2417 | if ( ret != MAILIMAP_NO_ERROR ) { | ||
2418 | res = ret; | ||
2419 | goto err; | ||
2420 | } | ||
2421 | // LR end | ||
2404 | } | 2422 | } |
2405 | } | 2423 | } |
2406 | else { | 2424 | else { |
diff --git a/libetpan/src/low-level/maildir/maildir.c b/libetpan/src/low-level/maildir/maildir.c index 98b9f87..e81625d 100644 --- a/libetpan/src/low-level/maildir/maildir.c +++ b/libetpan/src/low-level/maildir/maildir.c | |||
@@ -110,6 +110,8 @@ static char * maildir_get_new_message_filename(struct maildir * md, | |||
110 | char basename[PATH_MAX]; | 110 | char basename[PATH_MAX]; |
111 | int k; | 111 | int k; |
112 | time_t now; | 112 | time_t now; |
113 | //LR | ||
114 | struct stat f_stat; | ||
113 | int got_file; | 115 | int got_file; |
114 | int r; | 116 | int r; |
115 | 117 | ||
@@ -121,7 +123,18 @@ static char * maildir_get_new_message_filename(struct maildir * md, | |||
121 | (unsigned long) now, md->mdir_pid, md->mdir_counter, md->mdir_hostname); | 123 | (unsigned long) now, md->mdir_pid, md->mdir_counter, md->mdir_hostname); |
122 | snprintf(filename, sizeof(filename), "%s/tmp/%s", | 124 | snprintf(filename, sizeof(filename), "%s/tmp/%s", |
123 | md->mdir_path, basename); | 125 | md->mdir_path, basename); |
124 | 126 | ||
127 | // LR changed following lines | ||
128 | if ( stat( filename, &f_stat ) == -1 ) { | ||
129 | char * dup_filename; | ||
130 | |||
131 | dup_filename = strdup(filename); | ||
132 | if (dup_filename == NULL) { | ||
133 | //unlink(filename); | ||
134 | return NULL; | ||
135 | } | ||
136 | rename (tmpfile,dup_filename ); | ||
137 | #if 0 | ||
125 | if (link(tmpfile, filename) == 0) { | 138 | if (link(tmpfile, filename) == 0) { |
126 | got_file = 1; | 139 | got_file = 1; |
127 | unlink(tmpfile); | 140 | unlink(tmpfile); |
@@ -147,7 +160,7 @@ static char * maildir_get_new_message_filename(struct maildir * md, | |||
147 | unlink(filename); | 160 | unlink(filename); |
148 | return NULL; | 161 | return NULL; |
149 | } | 162 | } |
150 | 163 | #endif | |
151 | md->mdir_counter ++; | 164 | md->mdir_counter ++; |
152 | 165 | ||
153 | return dup_filename; | 166 | return dup_filename; |
diff --git a/libetpan/src/low-level/mh/mailmh.c b/libetpan/src/low-level/mh/mailmh.c index 42cab9d..f8c694d 100644 --- a/libetpan/src/low-level/mh/mailmh.c +++ b/libetpan/src/low-level/mh/mailmh.c | |||
@@ -920,6 +920,9 @@ int mailmh_folder_remove_message(struct mailmh_folder * folder, | |||
920 | #endif | 920 | #endif |
921 | chash_delete(folder->fl_msgs_hash, &key, NULL); | 921 | chash_delete(folder->fl_msgs_hash, &key, NULL); |
922 | } | 922 | } |
923 | // LR memory leak fixed | ||
924 | mailmh_msg_info_free( msg_info ); | ||
925 | free(filename); | ||
923 | 926 | ||
924 | return MAILMH_NO_ERROR; | 927 | return MAILMH_NO_ERROR; |
925 | 928 | ||
diff --git a/libetpan/src/low-level/pop3/mailpop3.c b/libetpan/src/low-level/pop3/mailpop3.c index 6f77a3a..bca62d5 100644 --- a/libetpan/src/low-level/pop3/mailpop3.c +++ b/libetpan/src/low-level/pop3/mailpop3.c | |||
@@ -508,8 +508,11 @@ int mailpop3_pass(mailpop3 * f, const char * password) | |||
508 | return MAILPOP3_ERROR_STREAM; | 508 | return MAILPOP3_ERROR_STREAM; |
509 | r = parse_response(f, response); | 509 | r = parse_response(f, response); |
510 | 510 | ||
511 | if (r != RESPONSE_OK) | 511 | if (r != RESPONSE_OK) { |
512 | return MAILPOP3_ERROR_BAD_PASSWORD; | 512 | // LR |
513 | fprintf(stderr,"POP3 login error. Response from server:\n%s\n",response ); | ||
514 | return MAILPOP3_ERROR_BAD_PASSWORD; | ||
515 | } | ||
513 | 516 | ||
514 | f->pop3_state = POP3_STATE_TRANSACTION; | 517 | f->pop3_state = POP3_STATE_TRANSACTION; |
515 | 518 | ||