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

Crash on nil chunks with message/rfc822 mail with invalid Content-Transfer-Encoding #209

Closed
alech opened this issue Jan 14, 2014 · 5 comments · Fixed by #210
Closed

Crash on nil chunks with message/rfc822 mail with invalid Content-Transfer-Encoding #209

alech opened this issue Jan 14, 2014 · 5 comments · Fixed by #210

Comments

@alech
Copy link

alech commented Jan 14, 2014

I recently received a mail with the following structure:

From: [email protected]
MIME-Version: 1.0
Content-type: multipart/report; boundary="======11647==82899======"; report-type="spam-notification"
Subject: Important

This is a multi-part message in MIME format...

--======11647==82899======
Content-Type: text/plain; charset="ISO-8859-1"
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable


--======11647==82899======
Content-Type: message/rfc822
Content-Disposition: attachment
Content-Transfer-Encoding: binary


--======11647==82899======--

After polling, sup crashed on me:

--- NoMethodError from thread: poll after loading inbox
private method `select' called for nil:NilClass
/usr/local/src/sup/lib/sup/message.rb:338:in `indexable_chunks'
/usr/local/src/sup/lib/sup/message.rb:334:in `indexable_body'
/usr/local/src/sup/lib/sup/index.rb:751:in `index_message_static'
/usr/local/src/sup/lib/sup/index.rb:714:in `sync_message'
/usr/local/src/sup/lib/sup/util.rb:649:in `method_missing'
/usr/local/src/sup/lib/sup/poll.rb:215:in `block in poll_from'
/usr/local/src/sup/lib/sup/maildir.rb:150:in `block in poll'
/usr/local/src/sup/lib/sup/maildir.rb:149:in `each'
/usr/local/src/sup/lib/sup/maildir.rb:149:in `each_with_index'
/usr/local/src/sup/lib/sup/maildir.rb:149:in `poll'
/usr/local/src/sup/lib/sup/poll.rb:201:in `poll_from'
/usr/local/src/sup/lib/sup/poll.rb:146:in `block (2 levels) in do_poll'
/usr/local/src/sup/lib/sup/poll.rb:136:in `each'
/usr/local/src/sup/lib/sup/poll.rb:136:in `block in do_poll'
:10:in `synchronize'
/usr/local/src/sup/lib/sup/poll.rb:135:in `do_poll'
/usr/local/src/sup/lib/sup/util.rb:649:in `method_missing'
/usr/local/src/sup/lib/sup/modes/poll_mode.rb:15:in `poll'
/usr/local/src/sup/lib/sup/poll.rb:58:in `poll_with_sources'
/usr/local/src/sup/lib/sup/poll.rb:94:in `poll'
/usr/local/src/sup/lib/sup/util.rb:649:in `method_missing'
bin/sup:220:in `block (2 levels) in '
/usr/local/src/sup/lib/sup.rb:87:in `block in reporting_thread'

I tracked this down to the inner Content-Transfer-Encoding: binary header, which sup considers invalid, leading to a RMail::EncodingUnsupportedError in message_to_chunks() (and apparently a nil chunks somewhere in the message parsing, which I didn't track down completely). A quick patch in message.rb allowed this particular message to be added correctly, but the problem persists with really invalid Content-Transfer-Encodings. A minimal message to demonstrate this is the following:

From: [email protected]
MIME-Version: 1.0
Subject: Content-Transfer-Encoding:-bug in sup
Content-Type: message/rfc822
Content-Transfer-Encoding: nosuchcontenttransferencoding

foo
@cro
Copy link

cro commented Jan 14, 2014

Will this problem go away when the switch to Mail from RMail is complete?

@gauteh
Copy link
Member

gauteh commented Jan 15, 2014

Thanks for your detailed report and example emails. It would certainly be easier to fix after Rmail-to-Mail-migration (#127) (which is not ready). But the problem, I think, is in Sup not ending up with an empty array [] and rather a nil. If there is no text/lines for the chunk it should be displayed as an attachment in the thread-view.

@gauteh
Copy link
Member

gauteh commented Jan 15, 2014

Could you test #210, I noticed that with a new debug message a chunks array would not be returned when a message could not be loaded. Your test messages have been added to the test-suite.

@alech
Copy link
Author

alech commented Jan 15, 2014

Tested #210, works for me - thanks for patching so fast :-)

@gauteh
Copy link
Member

gauteh commented Jan 15, 2014

Cool!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants