rspamd_string_find_eoh peeks p[1] in the got_cr state but guarded it
with "p < end", which is already guaranteed by the loop and does not
cover the p+1 access. On input whose header region ends with \r\r the
peek read one byte past the buffer; the MIME parser calls this with a
non-NUL-terminated GString view over the message, so that byte is not
guaranteed to exist.
Check p + 1 < end instead; a truncated \r\r at end of input then
falls through to the existing branch that treats it as end-of-headers.
* if it is '\n', then we have \r\r\n sequence, that is NOT
* double end of line
*/
- if (p < end && p[1] == '\n') {
+ if (p + 1 < end && p[1] == '\n') {
p++;
state = got_lf;
}