karastojko / mailio

mailio is a cross platform C++ library for MIME format and SMTP, POP3 and IMAP protocols. It is based on standard C++ 17 and Boost library.
Other
372 stars 98 forks source link

Line policy overflow in a header (mime.cpp) #166

Open Displacer opened 4 months ago

Displacer commented 4 months ago

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_linepolicy 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?

Displacer commented 4 months ago

setting codition to mailio::codec::line_len_policy_t::MANDATORY seems fixing this problem

karastojko commented 4 months ago

Correct, that's the purpose of the line policy.

Displacer commented 4 months ago

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)

Displacer commented 4 months ago

It seems decoder_linepolicy 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.

Displacer commented 4 months ago

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