Backport: do not believe negative result from FIONREAD.

svn:r1429
This commit is contained in:
Nick Mathewson 2009-09-11 18:55:06 +00:00
parent 8c6282ec39
commit 81765181c6
2 changed files with 5 additions and 2 deletions

View File

@ -1,3 +1,6 @@
Changes in 1.4.13-stable:
o If the kernel tells us that there are a negative number of bytes to read from a socket, do not believe it. Fixes bug 2841177; found by Alexander Pronchenkov.
Changes in 1.4.12-stable:
o Try to contain degree of failure when running on a win32 version so heavily firewalled that we can't fake a socketpair.
o Fix an obscure timing-dependent, allocator-dependent crash in the evdns code.

View File

@ -357,9 +357,9 @@ evbuffer_read(struct evbuffer *buf, int fd, int howmuch)
#if defined(FIONREAD)
#ifdef WIN32
long lng = n;
if (ioctlsocket(fd, FIONREAD, &lng) == -1 || (n=lng) == 0) {
if (ioctlsocket(fd, FIONREAD, &lng) == -1 || (n=lng) <= 0) {
#else
if (ioctl(fd, FIONREAD, &n) == -1 || n == 0) {
if (ioctl(fd, FIONREAD, &n) == -1 || n <= 0) {
#endif
n = EVBUFFER_MAX_READ;
} else if (n > EVBUFFER_MAX_READ && n > howmuch) {