Hallo nochmal Peter,

 |Peter Hofmann <[email protected]> wrote:
 ||when encoding strings using qp_encode(), they might get wrapped among
 ||multiple lines. qp_encode_calc_size() does not account for those
 ||additional line breaks, though, which can at least crash mail(1).
 |
 |Thanks for reporting this bug!

 |  $ LC_ALL=C PERL5OPT= perl -CS -e 'print "\x{101D0}" x 100' |
 |  MAILRC=/dev/null LC_ALL=en_US.UTF-8 s-nail -nvvd \
 |    -Ssendcharsets=utf8 -s testsub ./LETTER
 |
 ||qp_encode_calc_size() returns 1203 which is not enough. It should return
 ||at least 1233: Every input byte is encoded as three bytes (= 1200). This
 ||will span ceil(1200 / 76) = 16 lines, so we get an additional 30 bytes
 ||because every line break is "=\n". At the end of the encoded string,
 ||there might be a "=\n" as well, so add another 2. Including the NUL
 ||terminator, we end up at 1233.
 |
 |Absolutely correct analyzation.

Hmm, it seems i was too fast..  The soft NLs then add data
themselves, so what do you think about

   bytes = len * 3;
   lines = bytes / QP_LINESIZE;
   len += lines;

   bytes = len * 3;
   /* Trailing hard NL may be missing, so there may be two lines.
    * Thus add soft + hard NL per line and a trailing NUL */
   lines = (bytes / QP_LINESIZE) + 1;
   lines <<= 1;
   bytes += lines;
   len = ++bytes;

I think that should do it!?
That said i'm glad you found this error, it made me took the time
to rework the header MIME encoding a bit and at least v14.7.7 will
neither trigger the python bug (what i think) nor crash for
overlong header fields (S-nail) or generate invalid messages for
them (Heirloom mailx)!  It's still a long road though.

--steffen

------------------------------------------------------------------------------
Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer
Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports
Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper
Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer
http://pubads.g.doubleclick.net/gampad/clk?id=154622311&iu=/4140/ostg.clktrk
_______________________________________________
S-nail-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/s-nail-users

Reply via email to