leahneukirchen / mblaze

Unix utilities to deal with Maildir
Other
450 stars 50 forks source link

magrep crash when decoding large messages #76

Closed bentley closed 6 years ago

bentley commented 6 years ago

From /var/log/messages:

magrep: stack overflow in function magrep

Backtrace:

(gdb) run -d To:blah /tmp/,43446
The program being debugged has been started already.
Start it from the beginning? (y or n) y
Starting program: /tmp/mblaze/magrep -d To:example@example.com /tmp/,43446
could not read sequence '/home/anthony/.mblaze/seq': No such file or directory
/tmp/,43446

Program received signal SIGABRT, Aborted.
thrkill () at -:3
3       -: No such file or directory.
(gdb) bt
#0  thrkill () at -:3
#1  0x000009545e78f89b in _libc___stack_smash_handler (func=<optimized out>, 
    damaged=<optimized out>) at /usr/src/lib/libc/sys/stack_protector.c:79
#2  0x0000095199800f6c in magrep (file=0x7f7ffffebb05 "/tmp/,43446")
    at magrep.c:159
#3  0x00000951998041d3 in iterdir (dir=0x7f7ffffebb05 "/tmp/,43446", 
    cb=<optimized out>) at seq.c:481
#4  blaze822_loop (argc=<optimized out>, argv=<optimized out>, 
    cb=0x95199800d40 <magrep>) at seq.c:536
#5  0x00000951998010db in main (argc=<optimized out>, argv=0x7f7ffffeb918)
    at magrep.c:203

I can reproduce with the following file (I just added addresses until it started crashing):

To: "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>,
    "John Doe" <example@example.com>