imap4d from GNU Mailutils 3.17 dies with SIGSEGV while handling
FETCH ENVELOPE, when the message has a To address whose local-part
is a long chain of single-letter dot-atoms (a.a.a...a@b).

The cost is in libmailutils/address/parse822.c. mu_parse822_local_part
is right-recursive on "word '.' local-part". Each frame appends the
accumulated local-part with str_append. There is no depth limit. On
the default 8 MB stack the process runs out of stack between 64,000
and 100,000 dots.

Measured on the Ubuntu package (imap4d --version reports GNU Mailutils
3.17), ulimit -s = 8192, one fresh mbox per run, LF line endings,
imap4d --preauth, then SELECT INBOX and FETCH 1 (ENVELOPE):

    8,000 dots    16 KB   exit 0     67 ms
    32,000 dots   64 KB   exit 0    192 ms
    64,000 dots  128 KB   exit 0    317 ms
    64,000 dots, same size, no dots in the local-part: exit 0, 67 ms
    100,000 dots 200 KB   SIGSEGV (signal 11, shell status 139)

An earlier run on the same binary was 77 / 123 / 395 ms for 8k / 32k /
64k dots, and SIGSEGV at 100,000, 160,000, 240,000 and 320,000 dots.
The 64,000-dot message is about twice the 32,000-dot message and took
about 2.4 times as long. The no-dot control stayed flat.

This is a different path from the nested-multipart report sent on
2026-10-29. That one is mime.c and FETCH BODYSTRUCTURE. This one is
parse822.c and FETCH ENVELOPE.

Stock Postfix header_size_limit is 102,400 bytes, so a 200 KB To
header does not survive a default Postfix hop. The crashing message
does reach imap4d through a path that keeps the header, including
Exim, IMAP APPEND, and movemail. Below the crash, 128 KB already
costs several times a same-size address with no dots.

Rewriting the right recursion as a loop, and joining the atoms once,
removes both the stack growth and the repeated copy.

If this report is helpful, please attribute the report to Zhaoyang Li and
Xiang Li from AOSP Lab @Nankai University.

Reply via email to