-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 | |||
@@ -77,50 +77,57 @@ char * mailstream_read_line_append(mailstream * stream, MMAPString * line) | |||
77 | if (stream == NULL) | 77 | if (stream == NULL) |
78 | return NULL; | 78 | return NULL; |
79 | 79 | ||
80 | do { | 80 | do { |
81 | if (stream->read_buffer_len > 0) { | 81 | if (stream->read_buffer_len > 0) { |
82 | size_t i; | 82 | size_t i; |
83 | 83 | ||
84 | i = 0; | 84 | i = 0; |
85 | while (i < stream->read_buffer_len) { | 85 | while (i < stream->read_buffer_len) { |
86 | if (stream->read_buffer[i] == '\n') | 86 | if (stream->read_buffer[i] == '\n') |
87 | return mailstream_read_len_append(stream, line, i + 1); | 87 | return mailstream_read_len_append(stream, line, i + 1); |
88 | i++; | 88 | i++; |
89 | } | 89 | } |
90 | if (mailstream_read_len_append(stream, line, | 90 | if (mailstream_read_len_append(stream, line, |
91 | stream->read_buffer_len) == NULL) | 91 | stream->read_buffer_len) == NULL) |
92 | return NULL; | 92 | return NULL; |
93 | } | 93 | } |
94 | else { | 94 | else { |
95 | ssize_t r; | 95 | ssize_t r; |
96 | 96 | ||
97 | r = mailstream_feed_read_buffer(stream); | 97 | r = mailstream_feed_read_buffer(stream); |
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); |
106 | 113 | ||
107 | return line->str; | 114 | return line->str; |
108 | } | 115 | } |
109 | 116 | ||
110 | char * mailstream_read_line_remove_eol(mailstream * stream, MMAPString * line) | 117 | char * mailstream_read_line_remove_eol(mailstream * stream, MMAPString * line) |
111 | { | 118 | { |
112 | if (!mailstream_read_line(stream, line)) | 119 | if (!mailstream_read_line(stream, line)) |
113 | return NULL; | 120 | return NULL; |
114 | 121 | ||
115 | remove_trailing_eol(line); | 122 | remove_trailing_eol(line); |
116 | 123 | ||
117 | return line->str; | 124 | return line->str; |
118 | } | 125 | } |
119 | 126 | ||
120 | int mailstream_is_end_multiline(const char * line) | 127 | int mailstream_is_end_multiline(const char * line) |
121 | { | 128 | { |
122 | if (line[0] != '.') | 129 | if (line[0] != '.') |
123 | return FALSE; | 130 | return FALSE; |
124 | if (line[1] != 0) | 131 | if (line[1] != 0) |
125 | return FALSE; | 132 | return FALSE; |
126 | return TRUE; | 133 | return TRUE; |
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 | |||
@@ -228,71 +228,77 @@ static int pop3driver_parameters(mailsession * session, | |||
228 | { | 228 | { |
229 | struct pop3_session_state_data * data; | 229 | struct pop3_session_state_data * data; |
230 | 230 | ||
231 | data = get_data(session); | 231 | data = get_data(session); |
232 | 232 | ||
233 | switch (id) { | 233 | switch (id) { |
234 | case POP3DRIVER_SET_AUTH_TYPE: | 234 | case POP3DRIVER_SET_AUTH_TYPE: |
235 | { | 235 | { |
236 | int * param; | 236 | int * param; |
237 | 237 | ||
238 | param = value; | 238 | param = value; |
239 | 239 | ||
240 | data->pop3_auth_type = * param; | 240 | data->pop3_auth_type = * param; |
241 | return MAIL_NO_ERROR; | 241 | return MAIL_NO_ERROR; |
242 | } | 242 | } |
243 | } | 243 | } |
244 | 244 | ||
245 | return MAIL_ERROR_INVAL; | 245 | return MAIL_ERROR_INVAL; |
246 | } | 246 | } |
247 | 247 | ||
248 | static int pop3driver_login(mailsession * session, | 248 | 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 | ||
255 | data = get_data(session); | 257 | data = get_data(session); |
256 | 258 | ||
257 | switch (data->pop3_auth_type) { | 259 | switch (data->pop3_auth_type) { |
258 | case POP3DRIVER_AUTH_TYPE_TRY_APOP: | 260 | case POP3DRIVER_AUTH_TYPE_TRY_APOP: |
259 | r = mailpop3_login_apop(get_pop3_session(session), userid, password); | 261 | r = mailpop3_login_apop(get_pop3_session(session), userid, password); |
260 | if (r != MAILPOP3_NO_ERROR) | 262 | if (r != MAILPOP3_NO_ERROR) |
261 | r = mailpop3_login(get_pop3_session(session), userid, password); | 263 | r = mailpop3_login(get_pop3_session(session), userid, password); |
262 | break; | 264 | break; |
263 | 265 | ||
264 | case POP3DRIVER_AUTH_TYPE_APOP: | 266 | case POP3DRIVER_AUTH_TYPE_APOP: |
265 | r = mailpop3_login_apop(get_pop3_session(session), userid, password); | 267 | r = mailpop3_login_apop(get_pop3_session(session), userid, password); |
266 | break; | 268 | break; |
267 | 269 | ||
268 | default: | 270 | default: |
269 | case POP3DRIVER_AUTH_TYPE_PLAIN: | 271 | case POP3DRIVER_AUTH_TYPE_PLAIN: |
270 | r = mailpop3_login(get_pop3_session(session), userid, password); | 272 | r = mailpop3_login(get_pop3_session(session), userid, password); |
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 | } |
278 | 284 | ||
279 | static int pop3driver_logout(mailsession * session) | 285 | static int pop3driver_logout(mailsession * session) |
280 | { | 286 | { |
281 | int r; | 287 | int r; |
282 | 288 | ||
283 | r = mailpop3_quit(get_pop3_session(session)); | 289 | r = mailpop3_quit(get_pop3_session(session)); |
284 | 290 | ||
285 | return pop3driver_pop3_error_to_mail_error(r); | 291 | return pop3driver_pop3_error_to_mail_error(r); |
286 | } | 292 | } |
287 | 293 | ||
288 | static int pop3driver_noop(mailsession * session) | 294 | static int pop3driver_noop(mailsession * session) |
289 | { | 295 | { |
290 | int r; | 296 | int r; |
291 | 297 | ||
292 | r = mailpop3_noop(get_pop3_session(session)); | 298 | r = mailpop3_noop(get_pop3_session(session)); |
293 | 299 | ||
294 | return pop3driver_pop3_error_to_mail_error(r); | 300 | return pop3driver_pop3_error_to_mail_error(r); |
295 | } | 301 | } |
296 | 302 | ||
297 | static int pop3driver_status_folder(mailsession * session, char * mb, | 303 | static int pop3driver_status_folder(mailsession * session, char * mb, |
298 | uint32_t * result_messages, | 304 | uint32_t * result_messages, |
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 | |||
@@ -2378,50 +2378,68 @@ mailimap_body_fld_enc_parse(mailstream * fd, MMAPString * buffer, | |||
2378 | struct mailimap_body_fld_enc ** result, | 2378 | struct mailimap_body_fld_enc ** result, |
2379 | size_t progr_rate, | 2379 | size_t progr_rate, |
2380 | progress_function * progr_fun) | 2380 | progress_function * progr_fun) |
2381 | { | 2381 | { |
2382 | size_t cur_token; | 2382 | size_t cur_token; |
2383 | int type; | 2383 | int type; |
2384 | char * value; | 2384 | char * value; |
2385 | struct mailimap_body_fld_enc * body_fld_enc; | 2385 | struct mailimap_body_fld_enc * body_fld_enc; |
2386 | int r; | 2386 | int r; |
2387 | int res; | 2387 | int res; |
2388 | 2388 | ||
2389 | cur_token = * index; | 2389 | cur_token = * index; |
2390 | 2390 | ||
2391 | r = mailimap_body_fld_known_enc_parse(fd, buffer, &cur_token, | 2391 | r = mailimap_body_fld_known_enc_parse(fd, buffer, &cur_token, |
2392 | &type, progr_rate, progr_fun); | 2392 | &type, progr_rate, progr_fun); |
2393 | if (r == MAILIMAP_NO_ERROR) { | 2393 | if (r == MAILIMAP_NO_ERROR) { |
2394 | value = NULL; | 2394 | value = NULL; |
2395 | } | 2395 | } |
2396 | else if (r == MAILIMAP_ERROR_PARSE) { | 2396 | else if (r == MAILIMAP_ERROR_PARSE) { |
2397 | type = MAILIMAP_BODY_FLD_ENC_OTHER; | 2397 | type = MAILIMAP_BODY_FLD_ENC_OTHER; |
2398 | 2398 | ||
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 { |
2407 | res = r; | 2425 | res = r; |
2408 | goto err; | 2426 | goto err; |
2409 | } | 2427 | } |
2410 | 2428 | ||
2411 | body_fld_enc = mailimap_body_fld_enc_new(type, value); | 2429 | body_fld_enc = mailimap_body_fld_enc_new(type, value); |
2412 | if (body_fld_enc == NULL) { | 2430 | if (body_fld_enc == NULL) { |
2413 | res = MAILIMAP_ERROR_MEMORY; | 2431 | res = MAILIMAP_ERROR_MEMORY; |
2414 | goto value_free; | 2432 | goto value_free; |
2415 | } | 2433 | } |
2416 | 2434 | ||
2417 | * result = body_fld_enc; | 2435 | * result = body_fld_enc; |
2418 | * index = cur_token; | 2436 | * index = cur_token; |
2419 | 2437 | ||
2420 | return MAILIMAP_NO_ERROR; | 2438 | return MAILIMAP_NO_ERROR; |
2421 | 2439 | ||
2422 | value_free: | 2440 | value_free: |
2423 | if (value) | 2441 | if (value) |
2424 | mailimap_string_free(value); | 2442 | mailimap_string_free(value); |
2425 | err: | 2443 | err: |
2426 | return res; | 2444 | return res; |
2427 | } | 2445 | } |
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 | |||
@@ -89,86 +89,99 @@ struct maildir * maildir_new(const char * path) | |||
89 | err: | 89 | err: |
90 | return NULL; | 90 | return NULL; |
91 | } | 91 | } |
92 | 92 | ||
93 | static void maildir_flush(struct maildir * md, int msg_new); | 93 | static void maildir_flush(struct maildir * md, int msg_new); |
94 | 94 | ||
95 | void maildir_free(struct maildir * md) | 95 | void maildir_free(struct maildir * md) |
96 | { | 96 | { |
97 | maildir_flush(md, 0); | 97 | maildir_flush(md, 0); |
98 | maildir_flush(md, 1); | 98 | maildir_flush(md, 1); |
99 | chash_free(md->mdir_msg_hash); | 99 | chash_free(md->mdir_msg_hash); |
100 | carray_free(md->mdir_msg_list); | 100 | carray_free(md->mdir_msg_list); |
101 | free(md); | 101 | free(md); |
102 | } | 102 | } |
103 | 103 | ||
104 | #define MAX_TRY_ALLOC 32 | 104 | #define MAX_TRY_ALLOC 32 |
105 | 105 | ||
106 | static char * maildir_get_new_message_filename(struct maildir * md, | 106 | static char * maildir_get_new_message_filename(struct maildir * md, |
107 | char * tmpfile) | 107 | char * tmpfile) |
108 | { | 108 | { |
109 | char filename[PATH_MAX]; | 109 | char filename[PATH_MAX]; |
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 | ||
116 | got_file = 0; | 118 | got_file = 0; |
117 | now = time(NULL); | 119 | now = time(NULL); |
118 | k = 0; | 120 | k = 0; |
119 | while (k < MAX_TRY_ALLOC) { | 121 | while (k < MAX_TRY_ALLOC) { |
120 | snprintf(basename, sizeof(basename), "%lu.%u_%u.%s", | 122 | snprintf(basename, sizeof(basename), "%lu.%u_%u.%s", |
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); |
128 | } | 141 | } |
129 | else if (errno == EXDEV) { | 142 | else if (errno == EXDEV) { |
130 | unlink(tmpfile); | 143 | unlink(tmpfile); |
131 | return NULL; | 144 | return NULL; |
132 | } | 145 | } |
133 | else if (errno == EPERM) { | 146 | else if (errno == EPERM) { |
134 | r = rename(tmpfile, filename); | 147 | r = rename(tmpfile, filename); |
135 | if (r < 0) { | 148 | if (r < 0) { |
136 | unlink(tmpfile); | 149 | unlink(tmpfile); |
137 | return NULL; | 150 | return NULL; |
138 | } | 151 | } |
139 | got_file = 1; | 152 | got_file = 1; |
140 | } | 153 | } |
141 | 154 | ||
142 | if (got_file) { | 155 | if (got_file) { |
143 | char * dup_filename; | 156 | char * dup_filename; |
144 | 157 | ||
145 | dup_filename = strdup(filename); | 158 | dup_filename = strdup(filename); |
146 | if (dup_filename == NULL) { | 159 | if (dup_filename == NULL) { |
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; |
154 | } | 167 | } |
155 | 168 | ||
156 | md->mdir_counter ++; | 169 | md->mdir_counter ++; |
157 | k ++; | 170 | k ++; |
158 | } | 171 | } |
159 | 172 | ||
160 | return NULL; | 173 | return NULL; |
161 | } | 174 | } |
162 | 175 | ||
163 | 176 | ||
164 | static void msg_free(struct maildir_msg * msg) | 177 | static void msg_free(struct maildir_msg * msg) |
165 | { | 178 | { |
166 | free(msg->msg_uid); | 179 | free(msg->msg_uid); |
167 | free(msg->msg_filename); | 180 | free(msg->msg_filename); |
168 | free(msg); | 181 | free(msg); |
169 | } | 182 | } |
170 | 183 | ||
171 | /* | 184 | /* |
172 | msg_new() | 185 | msg_new() |
173 | 186 | ||
174 | filename is given without path | 187 | filename is given without path |
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 | |||
@@ -899,48 +899,51 @@ int mailmh_folder_remove_message(struct mailmh_folder * folder, | |||
899 | res = r; | 899 | res = r; |
900 | goto err; | 900 | goto err; |
901 | } | 901 | } |
902 | 902 | ||
903 | if (unlink(filename) == -1) { | 903 | if (unlink(filename) == -1) { |
904 | res = MAILMH_ERROR_FILE; | 904 | res = MAILMH_ERROR_FILE; |
905 | goto free; | 905 | goto free; |
906 | } | 906 | } |
907 | 907 | ||
908 | key.data = &index; | 908 | key.data = &index; |
909 | key.len = sizeof(index); | 909 | key.len = sizeof(index); |
910 | r = chash_get(folder->fl_msgs_hash, &key, &data); | 910 | r = chash_get(folder->fl_msgs_hash, &key, &data); |
911 | #if 0 | 911 | #if 0 |
912 | msg_info = cinthash_find(folder->fl_msgs_hash, index); | 912 | msg_info = cinthash_find(folder->fl_msgs_hash, index); |
913 | #endif | 913 | #endif |
914 | if (r == 0) { | 914 | if (r == 0) { |
915 | msg_info = data.data; | 915 | msg_info = data.data; |
916 | 916 | ||
917 | carray_delete_fast(folder->fl_msgs_tab, msg_info->msg_array_index); | 917 | carray_delete_fast(folder->fl_msgs_tab, msg_info->msg_array_index); |
918 | #if 0 | 918 | #if 0 |
919 | cinthash_remove(folder->fl_msgs_hash, index); | 919 | cinthash_remove(folder->fl_msgs_hash, index); |
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 | ||
926 | free: | 929 | free: |
927 | free(filename); | 930 | free(filename); |
928 | err: | 931 | err: |
929 | return res; | 932 | return res; |
930 | } | 933 | } |
931 | 934 | ||
932 | 935 | ||
933 | int mailmh_folder_move_message(struct mailmh_folder * dest_folder, | 936 | int mailmh_folder_move_message(struct mailmh_folder * dest_folder, |
934 | struct mailmh_folder * src_folder, | 937 | struct mailmh_folder * src_folder, |
935 | uint32_t index) | 938 | uint32_t index) |
936 | { | 939 | { |
937 | int fd; | 940 | int fd; |
938 | char * filename; | 941 | char * filename; |
939 | int r; | 942 | int r; |
940 | 943 | ||
941 | #if 0 | 944 | #if 0 |
942 | r = mailmh_folder_update(dest_folder); | 945 | r = mailmh_folder_update(dest_folder); |
943 | if (r != MAILMH_NO_ERROR) | 946 | if (r != MAILMH_NO_ERROR) |
944 | return r; | 947 | return r; |
945 | r = mailmh_folder_update(src_folder); | 948 | r = mailmh_folder_update(src_folder); |
946 | if (r != MAILMH_NO_ERROR) | 949 | if (r != MAILMH_NO_ERROR) |
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 | |||
@@ -487,50 +487,53 @@ int mailpop3_user(mailpop3 * f, const char * user) | |||
487 | return MAILPOP3_NO_ERROR; | 487 | return MAILPOP3_NO_ERROR; |
488 | } | 488 | } |
489 | 489 | ||
490 | int mailpop3_pass(mailpop3 * f, const char * password) | 490 | int mailpop3_pass(mailpop3 * f, const char * password) |
491 | { | 491 | { |
492 | char command[POP3_STRING_SIZE]; | 492 | char command[POP3_STRING_SIZE]; |
493 | int r; | 493 | int r; |
494 | char * response; | 494 | char * response; |
495 | 495 | ||
496 | if (f->pop3_state != POP3_STATE_AUTHORIZATION) | 496 | if (f->pop3_state != POP3_STATE_AUTHORIZATION) |
497 | return MAILPOP3_ERROR_BAD_STATE; | 497 | return MAILPOP3_ERROR_BAD_STATE; |
498 | 498 | ||
499 | /* send password command */ | 499 | /* send password command */ |
500 | 500 | ||
501 | snprintf(command, POP3_STRING_SIZE, "PASS %s\r\n", password); | 501 | snprintf(command, POP3_STRING_SIZE, "PASS %s\r\n", password); |
502 | r = send_command(f, command); | 502 | r = send_command(f, command); |
503 | if (r == -1) | 503 | if (r == -1) |
504 | return MAILPOP3_ERROR_STREAM; | 504 | return MAILPOP3_ERROR_STREAM; |
505 | 505 | ||
506 | response = read_line(f); | 506 | response = read_line(f); |
507 | if (response == NULL) | 507 | if (response == NULL) |
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 | ||
516 | return MAILPOP3_NO_ERROR; | 519 | return MAILPOP3_NO_ERROR; |
517 | } | 520 | } |
518 | 521 | ||
519 | static int read_list(mailpop3 * f, carray ** result); | 522 | static int read_list(mailpop3 * f, carray ** result); |
520 | 523 | ||
521 | 524 | ||
522 | 525 | ||
523 | static int read_uidl(mailpop3 * f, carray * msg_tab); | 526 | static int read_uidl(mailpop3 * f, carray * msg_tab); |
524 | 527 | ||
525 | 528 | ||
526 | 529 | ||
527 | static int mailpop3_do_uidl(mailpop3 * f, carray * msg_tab) | 530 | static int mailpop3_do_uidl(mailpop3 * f, carray * msg_tab) |
528 | { | 531 | { |
529 | char command[POP3_STRING_SIZE]; | 532 | char command[POP3_STRING_SIZE]; |
530 | int r; | 533 | int r; |
531 | char * response; | 534 | char * response; |
532 | 535 | ||
533 | if (f->pop3_state != POP3_STATE_TRANSACTION) | 536 | if (f->pop3_state != POP3_STATE_TRANSACTION) |
534 | return MAILPOP3_ERROR_BAD_STATE; | 537 | return MAILPOP3_ERROR_BAD_STATE; |
535 | 538 | ||
536 | /* send list command */ | 539 | /* send list command */ |