You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by bi...@apache.org on 2007/10/26 04:42:02 UTC
svn commit: r588479 -
/tomcat/tc6.0.x/trunk/java/org/apache/jk/common/ChannelNioSocket.java
Author: billbarker
Date: Thu Oct 25 19:41:57 2007
New Revision: 588479
URL: http://svn.apache.org/viewvc?rev=588479&view=rev
Log:
fix possible DoS condition when using the experimental NIO/AJP connector
Modified:
tomcat/tc6.0.x/trunk/java/org/apache/jk/common/ChannelNioSocket.java
Modified: tomcat/tc6.0.x/trunk/java/org/apache/jk/common/ChannelNioSocket.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/jk/common/ChannelNioSocket.java?rev=588479&r1=588478&r2=588479&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/jk/common/ChannelNioSocket.java (original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/jk/common/ChannelNioSocket.java Thu Oct 25 19:41:57 2007
@@ -36,6 +36,7 @@
import java.net.ServerSocket;
import java.net.Socket;
import java.net.SocketException;
+import java.net.SocketTimeoutException;
import javax.management.ListenerNotFoundException;
import javax.management.MBeanNotificationInfo;
@@ -46,6 +47,7 @@
import javax.management.NotificationListener;
import javax.management.ObjectName;
+import org.apache.commons.modeler.Registry;
import org.apache.jk.core.JkHandler;
import org.apache.jk.core.Msg;
import org.apache.jk.core.MsgContext;
@@ -54,7 +56,6 @@
import org.apache.coyote.Request;
import org.apache.coyote.RequestGroupInfo;
import org.apache.coyote.RequestInfo;
-import org.apache.tomcat.util.modeler.Registry;
import org.apache.tomcat.util.threads.ThreadPool;
import org.apache.tomcat.util.threads.ThreadPoolRunnable;
@@ -85,8 +86,8 @@
*/
public class ChannelNioSocket extends JkHandler
implements NotificationBroadcaster, JkChannel {
- private static org.apache.juli.logging.Log log =
- org.apache.juli.logging.LogFactory.getLog( ChannelNioSocket.class );
+ private static org.apache.commons.logging.Log log =
+ org.apache.commons.logging.LogFactory.getLog( ChannelNioSocket.class );
private int startPort=8009;
private int maxPort=8019; // 0 for backward compat.
@@ -172,7 +173,6 @@
return packetSize;
}
-
/**
* jmx:managed-attribute description="Bind on a specified address" access="READ_WRITE"
*/
@@ -883,6 +883,8 @@
synchronized void process(SelectionKey sk) {
if(!sk.isValid()) {
+ SocketInputStream sis = (SocketInputStream)ep.getNote(isNote);
+ sis.closeIt();
return;
}
if(sk.isReadable()) {
@@ -960,15 +962,11 @@
Iterator it = sels.iterator();
while(it.hasNext()) {
SelectionKey sk = (SelectionKey)it.next();
- if(sk.isValid()) {
- if(sk.isAcceptable()) {
- acceptConnections();
- } else {
- SocketConnection sc = (SocketConnection)sk.attachment();
- sc.process(sk);
- }
+ if(sk.isAcceptable()) {
+ acceptConnections();
} else {
- sk.cancel();
+ SocketConnection sc = (SocketConnection)sk.attachment();
+ sc.process(sk);
}
it.remove();
}
@@ -1082,8 +1080,7 @@
nr = -1; // Can't handle this yet
}
if(nr < 0) {
- isClosed = true;
- notify();
+ closeIt();
return false;
} else if(nr == 0) {
if(!nioIsBroken) {
@@ -1094,6 +1091,12 @@
return true;
}
+ synchronized void closeIt() {
+ isClosed = true;
+ if(blocking)
+ notify();
+ }
+
public int read(byte [] data) throws IOException {
return read(data, 0, data.length);
}
@@ -1133,7 +1136,9 @@
if(fill(len) < 0) {
isClosed = true;
}
- }
+ } else if(!isClosed) {
+ throw new SocketTimeoutException("Read request timed out");
+ }
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org