Bug #9083
closedlua/smtp: get_mime_list() skips the first MIME header
Description
- Status: present in
main(9b7938aec); code-confirmed - Class: off-by-one in a list API (first element silently omitted)
- Component:
src/util-lua-smtp.c:99-118(LuaSmtpTxGetMimeList) +rust/src/mime/smtp.rs:737-748
Description¶
get_mime_list() starts its index at num = 1 and passes that directly to the FFI, which uses it 0-based over the current MIME part's headers (headers[main_headers_nb + num]). The first header of the part is never returned.
Evidence: the existing suricata-verify/tests/lua/lua-smtplib test asserts fields[1] "Content-Transfer-Encoding" and #fields 2 for a part whose headers are actually [Content-Type, Content-Transfer-Encoding, Content-Disposition] - the dropped Content-Type (which can carry name=) is not asserted.
Trigger: any SMTP tx with MIME headers.
Fix direction¶
Pass num - 1 (or start from 0) so the first header is included; update the existing test to assert fields[1] "Content-Type" and #fields 3.
Test¶
lua-smtp-mime-list-first (or extend lua-smtplib).
JI Updated by Jason Ish about 1 month ago
- Status changed from New to In Review
MR1382
JI Updated by Jason Ish about 1 month ago
- Assignee set to Victor Julien