-
Notifications
You must be signed in to change notification settings - Fork 155
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_parse_received_date() avoid calling message_parse_string(hdr="")
#4771
message_parse_received_date() avoid calling message_parse_string(hdr="")
#4771
Conversation
as the latter does hdr = strchr(hdr+1, '\n') and hdr+1 is not allocated.
aa11be7
to
5f5503a
Compare
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.
The fix looks good, and the test proves that it fixes the invalid read. But the test itself fails... looks like a simple fix though, see suggestion inline.
struct body body; | ||
memset(&body, 0x45, sizeof(body)); | ||
CU_ASSERT_EQUAL(message_parse_mapped(msg, sizeof(msg)-1, &body, NULL), 0); | ||
CU_ASSERT_STRING_EQUAL(body.received_date, ""); |
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.
The test fails here with the fix, because when a semicolon with nothing after it is found, the original header value is used as the date string, which in this case is "abc;". But this line expects the empty string. It should expect "abc;", like this:
CU_ASSERT_STRING_EQUAL(body.received_date, ""); | |
CU_ASSERT_STRING_EQUAL(body.received_date, "abc;"); |
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.
Neither "abc"
nor ""
looks right to me. A non-existent date-time part in the header value should result in a NULL received_date value. The code building on body->received_date in lmtpd and jmap_mail is already prepared to handle NULL received_dates.
Thanks for submitting this. I will accept this as-is but will rewrite setting received_date to NULL on top of it. I'll then merge the updated PR so that CI succeeds. |
as the latter does
hdr = strchr(hdr+1, '\n')
andhdr+1
is not allocated.Without the change in message.c, calling
prints