瀏覽代碼

second attempt to properly commit patch for #3392

Christian Grothoff 11 年之前
父節點
當前提交
d71165ed3a
共有 2 個文件被更改,包括 11 次插入2 次删除
  1. 5 0
      ChangeLog
  2. 6 2
      src/microhttpd/connection.c

+ 5 - 0
ChangeLog

@@ -1,3 +1,8 @@
+Wed May 28 15:30:56 CEST 2014
+	Properly applying patch that was supposed to be
+	committed on "May  2 20:22:45 CEST 2014" to address
+	infinite loop (DoS) when HTTP connection is reset (#3392). -GM
+
 Sun May 25 20:18:27 CEST 2014
 	Fixed W32 build issues. -EG
 	Releasing 0.9.36. -CG

+ 6 - 2
src/microhttpd/connection.c

@@ -1620,9 +1620,13 @@ do_read (struct MHD_Connection *connection)
   if (bytes_read < 0)
     {
       const int err = MHD_socket_errno_;
-      if ((EINTR == err) || (EAGAIN == err) || (ECONNRESET == err)
-          || (EWOULDBLOCK == err))
+      if ((EINTR == err) || (EAGAIN == err) || (EWOULDBLOCK == err))
 	  return MHD_NO;
+      if (ECONNRESET == err)
+        {
+           CONNECTION_CLOSE_ERROR(connection, NULL);
+	   return MHD_NO;
+	}
 #if HAVE_MESSAGES
 #if HTTPS_SUPPORT
       if (0 != (connection->daemon->options & MHD_USE_SSL))