/ Zope / Apsis / Pound Mailing List / Archive / 2008 / 2008-05 / strip_eol() bug in pound-1.10

[ << ] [ >> ]

[ Suggestion about SSL Certificates / ... ] [ Session with "IP" does not work since ... ]

strip_eol() bug in pound-1.10
Rune Saetre <rst(at)folesvaert.no>
2008-05-11 19:44:47 [ FULL ]
Hi

We have found a bug with the strip_eol() function in pound-1.10 with
truncated headers.

The strip_eol() function searches a string for "\n" or "\r\n" and 
replaces this with "\0". The Pound-1.10 implementation does not check for
a terminating null character, so if no newline is found in the string it
scans the rest of the memory as well.

All headers include a newline character, so this usually works well.
Headers larger than MAXBUF are however truncated and the newline is lost,
and then pound usually segfaults.

The attached patch fixes this problem by also checking the string passed to
strip_eol() for a terminating null character.

I also added a bunch of "buf[MAXBUF-1] = '\0';" wherever BIO_gets() was 
called since I couldn't find any documentation stating that the strings
returned by BIO_gets() was guaranteed to be null terminated.

The patch has now been running for a while in production. No side effects 
has been detected, and Pound-1.10 has stopped segfaulting when it receives
requests or headers larger than 2k.

The patch is kept at http://folesvaert.no/pound/patches/
along with my other
Pound-1.10 patches.

Many thanks to Peter Pettersen for hunting down this bug!

Regards
Rune

--
Rune Saetre
rst(at)folesvaert.no
..
Attachments:  
patch-pound-1.10_truncated_header_bugfix_20080420.diff text/x-diff 4716 Bytes

Re: [Pound Mailing List] strip_eol() bug in pound-1.10
Robert Segall <roseg(at)apsis.ch>
2008-05-31 12:54:09 [ FULL ]
On Sun, 2008-05-11 at 19:44 +0200, Rune Saetre wrote:[...]

Many thanks for the information. If anybody is still running the 1.x
series the patch should be used.[...]

MailBoxer