author | alwin <alwin> | 2003-12-10 12:45:01 (UTC) |
---|---|---|
committer | alwin <alwin> | 2003-12-10 12:45:01 (UTC) |
commit | 66aa51039689ab2dab153469d7f6527bcedd9318 (patch) (unidiff) | |
tree | d27e68fa02af9c50514b9d9effcd67e28b86f66d | |
parent | b09fe710918a447f37c7ec92a6becb9953ada063 (diff) | |
download | opie-66aa51039689ab2dab153469d7f6527bcedd9318.zip opie-66aa51039689ab2dab153469d7f6527bcedd9318.tar.gz opie-66aa51039689ab2dab153469d7f6527bcedd9318.tar.bz2 |
when login failed for pop3 software crashed due not checked NULL pointer
-rw-r--r-- | noncore/net/mail/libmailwrapper/pop3wrapper.cpp | 1 | ||||
-rw-r--r-- | noncore/net/mail/pop3wrapper.cpp | 1 |
2 files changed, 2 insertions, 0 deletions
diff --git a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp index 2aaff30..72f3c36 100644 --- a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp +++ b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp | |||
@@ -1,93 +1,94 @@ | |||
1 | 1 | ||
2 | #include "pop3wrapper.h" | 2 | #include "pop3wrapper.h" |
3 | #include "mailtypes.h" | 3 | #include "mailtypes.h" |
4 | #include <libetpan/mailpop3.h> | 4 | #include <libetpan/mailpop3.h> |
5 | 5 | ||
6 | POP3wrapper::POP3wrapper( POP3account *a ) | 6 | POP3wrapper::POP3wrapper( POP3account *a ) |
7 | { | 7 | { |
8 | account = a; | 8 | account = a; |
9 | m_pop3 = NULL; | 9 | m_pop3 = NULL; |
10 | } | 10 | } |
11 | 11 | ||
12 | POP3wrapper::~POP3wrapper() | 12 | POP3wrapper::~POP3wrapper() |
13 | { | 13 | { |
14 | logout(); | 14 | logout(); |
15 | } | 15 | } |
16 | 16 | ||
17 | void POP3wrapper::pop3_progress( size_t current, size_t maximum ) | 17 | void POP3wrapper::pop3_progress( size_t current, size_t maximum ) |
18 | { | 18 | { |
19 | qDebug( "POP3: %i of %i", current, maximum ); | 19 | qDebug( "POP3: %i of %i", current, maximum ); |
20 | } | 20 | } |
21 | 21 | ||
22 | void POP3wrapper::listMessages( QList<RecMail> &target ) | 22 | void POP3wrapper::listMessages( QList<RecMail> &target ) |
23 | { | 23 | { |
24 | int err = MAILPOP3_NO_ERROR; | 24 | int err = MAILPOP3_NO_ERROR; |
25 | char *header; | 25 | char *header; |
26 | size_t length; | 26 | size_t length; |
27 | carray *messages; | 27 | carray *messages; |
28 | 28 | ||
29 | login(); | 29 | login(); |
30 | if (!m_pop3) return; | ||
30 | mailpop3_list( m_pop3, &messages ); | 31 | mailpop3_list( m_pop3, &messages ); |
31 | 32 | ||
32 | for ( int i = carray_count( messages ); i > 0; i-- ) { | 33 | for ( int i = carray_count( messages ); i > 0; i-- ) { |
33 | mailpop3_msg_info *info = (mailpop3_msg_info *) carray_get( messages, i - 1 ); | 34 | mailpop3_msg_info *info = (mailpop3_msg_info *) carray_get( messages, i - 1 ); |
34 | 35 | ||
35 | err = mailpop3_header( m_pop3, info->index, &header, &length ); | 36 | err = mailpop3_header( m_pop3, info->index, &header, &length ); |
36 | if ( err != MAILPOP3_NO_ERROR ) { | 37 | if ( err != MAILPOP3_NO_ERROR ) { |
37 | qDebug( "POP3: error retrieving header msgid: %i", info->index ); | 38 | qDebug( "POP3: error retrieving header msgid: %i", info->index ); |
38 | logout(); | 39 | logout(); |
39 | return; | 40 | return; |
40 | } | 41 | } |
41 | RecMail *mail = parseHeader( header ); | 42 | RecMail *mail = parseHeader( header ); |
42 | mail->setNumber( info->index ); | 43 | mail->setNumber( info->index ); |
43 | target.append( mail ); | 44 | target.append( mail ); |
44 | } | 45 | } |
45 | 46 | ||
46 | logout(); | 47 | logout(); |
47 | } | 48 | } |
48 | 49 | ||
49 | RecMail *POP3wrapper::parseHeader( const char *header ) | 50 | RecMail *POP3wrapper::parseHeader( const char *header ) |
50 | { | 51 | { |
51 | int err = MAILIMF_NO_ERROR; | 52 | int err = MAILIMF_NO_ERROR; |
52 | size_t curTok; | 53 | size_t curTok; |
53 | RecMail *mail = new RecMail(); | 54 | RecMail *mail = new RecMail(); |
54 | mailimf_fields *fields; | 55 | mailimf_fields *fields; |
55 | 56 | ||
56 | err = mailimf_fields_parse( (char *) header, strlen( header ), &curTok, &fields ); | 57 | err = mailimf_fields_parse( (char *) header, strlen( header ), &curTok, &fields ); |
57 | for ( clistiter *current = clist_begin( fields->list ); current != NULL; current = current->next ) { | 58 | for ( clistiter *current = clist_begin( fields->list ); current != NULL; current = current->next ) { |
58 | mailimf_field *field = (mailimf_field *) current->data; | 59 | mailimf_field *field = (mailimf_field *) current->data; |
59 | switch ( field->type ) { | 60 | switch ( field->type ) { |
60 | case MAILIMF_FIELD_FROM: | 61 | case MAILIMF_FIELD_FROM: |
61 | mail->setFrom( *parseMailboxList( field->field.from->mb_list ) ); | 62 | mail->setFrom( *parseMailboxList( field->field.from->mb_list ) ); |
62 | break; | 63 | break; |
63 | case MAILIMF_FIELD_TO: | 64 | case MAILIMF_FIELD_TO: |
64 | mail->setTo( *parseAddressList( field->field.to->addr_list ) ); | 65 | mail->setTo( *parseAddressList( field->field.to->addr_list ) ); |
65 | break; | 66 | break; |
66 | case MAILIMF_FIELD_CC: | 67 | case MAILIMF_FIELD_CC: |
67 | mail->setCC( *parseAddressList( field->field.cc->addr_list ) ); | 68 | mail->setCC( *parseAddressList( field->field.cc->addr_list ) ); |
68 | break; | 69 | break; |
69 | case MAILIMF_FIELD_BCC: | 70 | case MAILIMF_FIELD_BCC: |
70 | mail->setBcc( *parseAddressList( field->field.bcc->addr_list ) ); | 71 | mail->setBcc( *parseAddressList( field->field.bcc->addr_list ) ); |
71 | break; | 72 | break; |
72 | case MAILIMF_FIELD_SUBJECT: | 73 | case MAILIMF_FIELD_SUBJECT: |
73 | mail->setSubject( QString( field->field.subject->value ) ); | 74 | mail->setSubject( QString( field->field.subject->value ) ); |
74 | break; | 75 | break; |
75 | case MAILIMF_FIELD_ORIG_DATE: | 76 | case MAILIMF_FIELD_ORIG_DATE: |
76 | mail->setDate( *parseDateTime( field->field.orig_date->date_time ) ); | 77 | mail->setDate( *parseDateTime( field->field.orig_date->date_time ) ); |
77 | break; | 78 | break; |
78 | default: | 79 | default: |
79 | break; | 80 | break; |
80 | } | 81 | } |
81 | } | 82 | } |
82 | 83 | ||
83 | return mail; | 84 | return mail; |
84 | } | 85 | } |
85 | 86 | ||
86 | QString *POP3wrapper::parseDateTime( mailimf_date_time *date ) | 87 | QString *POP3wrapper::parseDateTime( mailimf_date_time *date ) |
87 | { | 88 | { |
88 | char tmp[23]; | 89 | char tmp[23]; |
89 | 90 | ||
90 | snprintf( tmp, 23, "%02i.%02i.%04i %02i:%02i:%02i %+05i", | 91 | snprintf( tmp, 23, "%02i.%02i.%04i %02i:%02i:%02i %+05i", |
91 | date->day, date->month, date->year, date->hour, date->min, date->sec, date->zone ); | 92 | date->day, date->month, date->year, date->hour, date->min, date->sec, date->zone ); |
92 | 93 | ||
93 | QString *result = new QString( tmp ); | 94 | QString *result = new QString( tmp ); |
diff --git a/noncore/net/mail/pop3wrapper.cpp b/noncore/net/mail/pop3wrapper.cpp index 2aaff30..72f3c36 100644 --- a/noncore/net/mail/pop3wrapper.cpp +++ b/noncore/net/mail/pop3wrapper.cpp | |||
@@ -1,93 +1,94 @@ | |||
1 | 1 | ||
2 | #include "pop3wrapper.h" | 2 | #include "pop3wrapper.h" |
3 | #include "mailtypes.h" | 3 | #include "mailtypes.h" |
4 | #include <libetpan/mailpop3.h> | 4 | #include <libetpan/mailpop3.h> |
5 | 5 | ||
6 | POP3wrapper::POP3wrapper( POP3account *a ) | 6 | POP3wrapper::POP3wrapper( POP3account *a ) |
7 | { | 7 | { |
8 | account = a; | 8 | account = a; |
9 | m_pop3 = NULL; | 9 | m_pop3 = NULL; |
10 | } | 10 | } |
11 | 11 | ||
12 | POP3wrapper::~POP3wrapper() | 12 | POP3wrapper::~POP3wrapper() |
13 | { | 13 | { |
14 | logout(); | 14 | logout(); |
15 | } | 15 | } |
16 | 16 | ||
17 | void POP3wrapper::pop3_progress( size_t current, size_t maximum ) | 17 | void POP3wrapper::pop3_progress( size_t current, size_t maximum ) |
18 | { | 18 | { |
19 | qDebug( "POP3: %i of %i", current, maximum ); | 19 | qDebug( "POP3: %i of %i", current, maximum ); |
20 | } | 20 | } |
21 | 21 | ||
22 | void POP3wrapper::listMessages( QList<RecMail> &target ) | 22 | void POP3wrapper::listMessages( QList<RecMail> &target ) |
23 | { | 23 | { |
24 | int err = MAILPOP3_NO_ERROR; | 24 | int err = MAILPOP3_NO_ERROR; |
25 | char *header; | 25 | char *header; |
26 | size_t length; | 26 | size_t length; |
27 | carray *messages; | 27 | carray *messages; |
28 | 28 | ||
29 | login(); | 29 | login(); |
30 | if (!m_pop3) return; | ||
30 | mailpop3_list( m_pop3, &messages ); | 31 | mailpop3_list( m_pop3, &messages ); |
31 | 32 | ||
32 | for ( int i = carray_count( messages ); i > 0; i-- ) { | 33 | for ( int i = carray_count( messages ); i > 0; i-- ) { |
33 | mailpop3_msg_info *info = (mailpop3_msg_info *) carray_get( messages, i - 1 ); | 34 | mailpop3_msg_info *info = (mailpop3_msg_info *) carray_get( messages, i - 1 ); |
34 | 35 | ||
35 | err = mailpop3_header( m_pop3, info->index, &header, &length ); | 36 | err = mailpop3_header( m_pop3, info->index, &header, &length ); |
36 | if ( err != MAILPOP3_NO_ERROR ) { | 37 | if ( err != MAILPOP3_NO_ERROR ) { |
37 | qDebug( "POP3: error retrieving header msgid: %i", info->index ); | 38 | qDebug( "POP3: error retrieving header msgid: %i", info->index ); |
38 | logout(); | 39 | logout(); |
39 | return; | 40 | return; |
40 | } | 41 | } |
41 | RecMail *mail = parseHeader( header ); | 42 | RecMail *mail = parseHeader( header ); |
42 | mail->setNumber( info->index ); | 43 | mail->setNumber( info->index ); |
43 | target.append( mail ); | 44 | target.append( mail ); |
44 | } | 45 | } |
45 | 46 | ||
46 | logout(); | 47 | logout(); |
47 | } | 48 | } |
48 | 49 | ||
49 | RecMail *POP3wrapper::parseHeader( const char *header ) | 50 | RecMail *POP3wrapper::parseHeader( const char *header ) |
50 | { | 51 | { |
51 | int err = MAILIMF_NO_ERROR; | 52 | int err = MAILIMF_NO_ERROR; |
52 | size_t curTok; | 53 | size_t curTok; |
53 | RecMail *mail = new RecMail(); | 54 | RecMail *mail = new RecMail(); |
54 | mailimf_fields *fields; | 55 | mailimf_fields *fields; |
55 | 56 | ||
56 | err = mailimf_fields_parse( (char *) header, strlen( header ), &curTok, &fields ); | 57 | err = mailimf_fields_parse( (char *) header, strlen( header ), &curTok, &fields ); |
57 | for ( clistiter *current = clist_begin( fields->list ); current != NULL; current = current->next ) { | 58 | for ( clistiter *current = clist_begin( fields->list ); current != NULL; current = current->next ) { |
58 | mailimf_field *field = (mailimf_field *) current->data; | 59 | mailimf_field *field = (mailimf_field *) current->data; |
59 | switch ( field->type ) { | 60 | switch ( field->type ) { |
60 | case MAILIMF_FIELD_FROM: | 61 | case MAILIMF_FIELD_FROM: |
61 | mail->setFrom( *parseMailboxList( field->field.from->mb_list ) ); | 62 | mail->setFrom( *parseMailboxList( field->field.from->mb_list ) ); |
62 | break; | 63 | break; |
63 | case MAILIMF_FIELD_TO: | 64 | case MAILIMF_FIELD_TO: |
64 | mail->setTo( *parseAddressList( field->field.to->addr_list ) ); | 65 | mail->setTo( *parseAddressList( field->field.to->addr_list ) ); |
65 | break; | 66 | break; |
66 | case MAILIMF_FIELD_CC: | 67 | case MAILIMF_FIELD_CC: |
67 | mail->setCC( *parseAddressList( field->field.cc->addr_list ) ); | 68 | mail->setCC( *parseAddressList( field->field.cc->addr_list ) ); |
68 | break; | 69 | break; |
69 | case MAILIMF_FIELD_BCC: | 70 | case MAILIMF_FIELD_BCC: |
70 | mail->setBcc( *parseAddressList( field->field.bcc->addr_list ) ); | 71 | mail->setBcc( *parseAddressList( field->field.bcc->addr_list ) ); |
71 | break; | 72 | break; |
72 | case MAILIMF_FIELD_SUBJECT: | 73 | case MAILIMF_FIELD_SUBJECT: |
73 | mail->setSubject( QString( field->field.subject->value ) ); | 74 | mail->setSubject( QString( field->field.subject->value ) ); |
74 | break; | 75 | break; |
75 | case MAILIMF_FIELD_ORIG_DATE: | 76 | case MAILIMF_FIELD_ORIG_DATE: |
76 | mail->setDate( *parseDateTime( field->field.orig_date->date_time ) ); | 77 | mail->setDate( *parseDateTime( field->field.orig_date->date_time ) ); |
77 | break; | 78 | break; |
78 | default: | 79 | default: |
79 | break; | 80 | break; |
80 | } | 81 | } |
81 | } | 82 | } |
82 | 83 | ||
83 | return mail; | 84 | return mail; |
84 | } | 85 | } |
85 | 86 | ||
86 | QString *POP3wrapper::parseDateTime( mailimf_date_time *date ) | 87 | QString *POP3wrapper::parseDateTime( mailimf_date_time *date ) |
87 | { | 88 | { |
88 | char tmp[23]; | 89 | char tmp[23]; |
89 | 90 | ||
90 | snprintf( tmp, 23, "%02i.%02i.%04i %02i:%02i:%02i %+05i", | 91 | snprintf( tmp, 23, "%02i.%02i.%04i %02i:%02i:%02i %+05i", |
91 | date->day, date->month, date->year, date->hour, date->min, date->sec, date->zone ); | 92 | date->day, date->month, date->year, date->hour, date->min, date->sec, date->zone ); |
92 | 93 | ||
93 | QString *result = new QString( tmp ); | 94 | QString *result = new QString( tmp ); |