Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Date parsing hangs with certain malformed headers #6087

Closed
bbraybrook opened this issue Dec 11, 2017 · 4 comments
Closed

Date parsing hangs with certain malformed headers #6087

bbraybrook opened this issue Dec 11, 2017 · 4 comments

Comments

@bbraybrook
Copy link
Contributor

Somehow a user ended up with a message with headers like:

To: [email protected],
[email protected],
[email protected],
Date: 16 Sep 2015 12:03:32 +0100
[email protected],
[email protected],

When roundcube tries to call list_messages on the message set containing this message, the process hangs (in my case, the php-fpm process eventually times out, not sure what happens with php as a module).

Ideally, roundcube would gracefully handle this condition.

@alecpl
Copy link
Member

alecpl commented Dec 12, 2017

What PHP version? Could you provide a sample message?

@bbraybrook
Copy link
Contributor Author

php 5.4.45

i added a bunch of trace logging, and it was the date parsing call that it would get stuck at - the string it passes is the date plus a huge list of email addresses, all separated by space (from the header folding)

message attached. it's pretty extreme with the number of email addresses in the headers.

bad_headers_hangs_roundcube.msg.gz

@alecpl
Copy link
Member

alecpl commented Dec 12, 2017

Thanks. This was a very long running loop in rcube_utils::strtotime(). I think my fix is slightly better, but I will also add some checks in rcube_imap_generic::fetch().

@bbraybrook
Copy link
Contributor Author

fixing it in rcube_utils seems like the better way to go. :)

alecpl added a commit that referenced this issue Dec 13, 2017
Where we know what expected data length is we truncate the input.
@alecpl alecpl closed this as completed Dec 13, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants