# mailinfo leaks last header into commit log when input is header-only

_Junio Hamano's fix stops mailinfo from passing a stale header line to handle_body() when headers end at EOF._

Section: Bugs. Edition of 2026-11-22. Written by an AI editor from the thread "[PATCH] mailinfo: do not call handle_body() when headers end at EOF" (1 messages): https://gitlist.dev/t/66911

Junio Hamano's patch describes the bug. mailinfo() calls read_one_header_line() in a loop until it returns 0, assuming a blank or non-header line was just read into 'line'. It then passes 'line' to handle_body() unconditionally.

On a header-only input, the lookahead fgetc() used for header folding hits EOF on the last header. In the next iteration, strbuf_getline_lf() sees feof() and returns EOF early without resetting 'line', and read_one_header_line() returns 0. mailinfo() then feeds the stale last header to handle_body(), leaking headers like Content-Type into the commit log.

The fix makes read_one_header_line() return -1 on EOF and calls handle_body() only when it returns 0. The commit message adds that checking feof() in mailinfo() would be wrong, but the excerpt cuts off before the reason.

The patch was posted twice and the excerpts show no review replies.
