-
Notifications
You must be signed in to change notification settings - Fork 154
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
message.c: reject to parse MIME headers with NUL byte #5205
base: master
Are you sure you want to change the base?
message.c: reject to parse MIME headers with NUL byte #5205
Conversation
@@ -4956,7 +4969,8 @@ static int body_foreach_section(struct body *body, struct message *message, | |||
msg.len = body->header_size; | |||
msg.offset = 0; | |||
msg.encode = 0; | |||
message_parse_headers(&msg, tmpbody, "text/plain", &boundaries, NULL); | |||
message_parse_headers(&msg, tmpbody, "text/plain", &boundaries, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kinda surprised we don't care about errors in parsing here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here, we parse the headers for on an already parsed body-part here, e.g. these headers already were validated otherwise that body part wouldn't exist. We didn't check for errors previously here, because message_parse_headers didn't check for any.
It might be good to check for message_parse_headers errors here, too, but in case of errors it's a very different situation we are in: it means that an already accepted email on disk could now not be read anymore. We would need to treat this differently and I'd prefer to keep the damage radius of this change small.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(couple of style nits)
It does, but so far the test fails because of an IOERROR logged while parsing the message.
Before, the parse continued but set incorrect header and body offsets for the body part. This resulted in log spam noting the discrepancy between the file size and header+body offsets, as well as a bogus in-memory MIME body structure.
aeebe14
to
f56c25f
Compare
Before, the parse continued but set incorrect header and body offsets for the body part. This resulted in log spam noting the discrepancy between the file size and header+body offsets, as well as a bogus in-memory MIME body structure.