]> granicus.if.org Git - libevent/commitdiff
Treat a negative number of bytes to read as the kernel saying "I don't know."
authorNick Mathewson <nickm@torproject.org>
Fri, 11 Sep 2009 18:21:37 +0000 (18:21 +0000)
committerNick Mathewson <nickm@torproject.org>
Fri, 11 Sep 2009 18:21:37 +0000 (18:21 +0000)
svn:r1426

ChangeLog
buffer.c

index cb4900af28fc82478195571b86ae4e85536b8a30..fa69e4a44e48cf43bf1c62da7b72eb6d8b8a76c6 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -17,7 +17,7 @@ Changes in 2.0.3-alpha:
  o Support sendfile on Solaris: patch from Caitlin Mercer.
  o New functions to explicitly reference a socket used by an evhttp object. Patches from David Reiss.
  o When we send a BEV_EVENT_CONNECTED to indicate connected status, we no longer invoke the write callback as well unless we actually wrote data too.
-
+ 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 2.0.2-alpha:
  o Add a new flag to bufferevents to make all callbacks automatically deferred.
index 0cd6df50ba534d846975936f53259c7b86c50075..370823e2ba912f1f354ca2396d39122a58cbc98a 100644 (file)
--- a/buffer.c
+++ b/buffer.c
@@ -1607,9 +1607,9 @@ evbuffer_read(struct evbuffer *buf, evutil_socket_t fd, int howmuch)
 
 #if defined(FIONREAD)
 #ifdef WIN32
-       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) {