aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2013-09-02 21:00:31 +0000
committerChristian Grothoff <christian@grothoff.org>2013-09-02 21:00:31 +0000
commit41d2fc1eba51dbb1c2c23d83d18e985f92cd6d53 (patch)
treebf7f61d795f50988cbdb08fde09861d91bdba6e5
parent90acb6bbbd28beac0567e383a8572b21238a19a4 (diff)
downloadlibmicrohttpd-41d2fc1eba51dbb1c2c23d83d18e985f92cd6d53.tar.gz
libmicrohttpd-41d2fc1eba51dbb1c2c23d83d18e985f92cd6d53.zip
fix epoll use after free
-rw-r--r--ChangeLog3
-rw-r--r--src/microhttpd/connection.c8
-rw-r--r--src/microhttpd/daemon.c7
3 files changed, 13 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 2791f68a..9fcf977a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,6 @@
1Mon Sep 2 22:59:45 CEST 2013
2 Fix use-after-free in epoll()-mode on read error. -CG
3
1Sun Sep 1 21:55:53 CEST 2013 4Sun Sep 1 21:55:53 CEST 2013
2 Fixing build issues on FreeBSD. -CG 5 Fixing build issues on FreeBSD. -CG
3 6
diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c
index 48a07cf4..2e5979c5 100644
--- a/src/microhttpd/connection.c
+++ b/src/microhttpd/connection.c
@@ -1824,7 +1824,7 @@ int
1824MHD_connection_handle_read (struct MHD_Connection *connection) 1824MHD_connection_handle_read (struct MHD_Connection *connection)
1825{ 1825{
1826 update_last_activity (connection); 1826 update_last_activity (connection);
1827 if (connection->state == MHD_CONNECTION_CLOSED) 1827 if (MHD_CONNECTION_CLOSED == connection->state)
1828 return MHD_YES; 1828 return MHD_YES;
1829 /* make sure "read" has a reasonable number of bytes 1829 /* make sure "read" has a reasonable number of bytes
1830 in buffer to use per system call (if possible) */ 1830 in buffer to use per system call (if possible) */
@@ -2169,13 +2169,13 @@ MHD_connection_handle_idle (struct MHD_Connection *connection)
2169 continue; 2169 continue;
2170 case MHD_CONNECTION_HEADERS_RECEIVED: 2170 case MHD_CONNECTION_HEADERS_RECEIVED:
2171 parse_connection_headers (connection); 2171 parse_connection_headers (connection);
2172 if (connection->state == MHD_CONNECTION_CLOSED) 2172 if (MHD_CONNECTION_CLOSED == connection->state)
2173 continue; 2173 continue;
2174 connection->state = MHD_CONNECTION_HEADERS_PROCESSED; 2174 connection->state = MHD_CONNECTION_HEADERS_PROCESSED;
2175 continue; 2175 continue;
2176 case MHD_CONNECTION_HEADERS_PROCESSED: 2176 case MHD_CONNECTION_HEADERS_PROCESSED:
2177 call_connection_handler (connection); /* first call */ 2177 call_connection_handler (connection); /* first call */
2178 if (connection->state == MHD_CONNECTION_CLOSED) 2178 if (MHD_CONNECTION_CLOSED == connection->state)
2179 continue; 2179 continue;
2180 if (need_100_continue (connection)) 2180 if (need_100_continue (connection))
2181 { 2181 {
@@ -2208,7 +2208,7 @@ MHD_connection_handle_idle (struct MHD_Connection *connection)
2208 if (connection->read_buffer_offset != 0) 2208 if (connection->read_buffer_offset != 0)
2209 { 2209 {
2210 process_request_body (connection); /* loop call */ 2210 process_request_body (connection); /* loop call */
2211 if (connection->state == MHD_CONNECTION_CLOSED) 2211 if (MHD_CONNECTION_CLOSED == connection->state)
2212 continue; 2212 continue;
2213 } 2213 }
2214 if ((connection->remaining_upload_size == 0) || 2214 if ((connection->remaining_upload_size == 0) ||
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c
index 5d99fa40..b8bb7b3d 100644
--- a/src/microhttpd/daemon.c
+++ b/src/microhttpd/daemon.c
@@ -1591,7 +1591,12 @@ MHD_cleanup_connections (struct MHD_Daemon *daemon)
1591 pos->addr_len); 1591 pos->addr_len);
1592#if EPOLL_SUPPORT 1592#if EPOLL_SUPPORT
1593 if (0 != (pos->epoll_state & MHD_EPOLL_STATE_IN_EREADY_EDLL)) 1593 if (0 != (pos->epoll_state & MHD_EPOLL_STATE_IN_EREADY_EDLL))
1594 MHD_PANIC ("Internal error"); 1594 {
1595 EDLL_remove (daemon->eready_head,
1596 daemon->eready_tail,
1597 pos);
1598 pos->epoll_state &= ~MHD_EPOLL_STATE_IN_EREADY_EDLL;
1599 }
1595 if ( (0 != (daemon->options & MHD_USE_EPOLL_LINUX_ONLY)) && 1600 if ( (0 != (daemon->options & MHD_USE_EPOLL_LINUX_ONLY)) &&
1596 (-1 != daemon->epoll_fd) && 1601 (-1 != daemon->epoll_fd) &&
1597 (0 != (pos->epoll_state & MHD_EPOLL_STATE_IN_EPOLL_SET)) ) 1602 (0 != (pos->epoll_state & MHD_EPOLL_STATE_IN_EPOLL_SET)) )