Line policy overflow in a header (mime.cpp)
There is a condition for line.length() in mime.cpp parse_by_line function:
if (line.length() > string::size_type(decoder_line_policy_))
throw mime_error("Line policy overflow in a header.");
decoder_line_policy_ is set to mailio::codec::line_len_policy_t::RECOMMENDED which equals 73.
In some cases MS Exchange mail server produces lines with larger size, leading to exception thrown.
Can this value be increased to support such messages?
setting codition to mailio::codec::line_len_policy_t::MANDATORY seems fixing this problem
Correct, that's the purpose of the line policy.
Correct, that's the purpose of the line policy.
I have provided pull request https://github.com/karastojko/mailio/pull/167 to quick merge if this is correct changes.
PS: There is also pull request to support boost versions before 1.81 (Ubuntu 22.04 LTS have 1.74)
It seems decoder_line_policy_ should be set for mailio::codec::line_len_policy_t::MANDATORY in class initialization since there are overflows in mailio::bit8::decode (line 80) in some cases with RECOMMENDED value.
there seems to be a problem in imap.cpp (line 458): msg.line_policy(line_policy, line_policy); the second parameter of msg.line_policy seems should be MANDATORY also
I have the same issue. In my case, the IMAP server is ionos.com. So, to fix it, I need to modify the source and build the project, right? Right now, I am using vcpkg for this library.
I have the same issue. In my case, the IMAP server is ionos.com. So, to fix it, I need to modify the source and build the project, right? Right now, I am using vcpkg for this library.
You probably could try something like this in client code without rebuilding library:
message msg; msg.line_policy(codec::line_len_policy_t::MANDATORY, codec::line_len_policy_t::MANDATORY); conn.fetch(msg_uid, msg);
I hope this will help.
@Displacer That's right.
There is also the NONE policy which means unlimited.
Thank you, guys, it helped, but unfortunately, while fetching other emails, I get SIGSEGV.
code snippet:
for (const auto msg_uid : messages) {
message msg;
msg.line_policy(codec::line_len_policy_t::NONE,
codec::line_len_policy_t::NONE);
conn.fetch(msg_uid, msg);
if (!msg.empty()) {
cout << msg.subject() << endl;
}
}
Thanks for the report. Can you please in the method mime::content_type_t::operator=(const mime::content_type_t&) before the line with to_lower_copy put printing of cont_type.subtype and paste the result here? I am interested to understand the reason of the crash of to_lower_copy() in your case.