summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-01-10 03:30:42 (EST)
committerEike Stepper2007-01-10 03:30:42 (EST)
commit8206524ac2d1fa4a42d41c54ce59bdd07ccf8741 (patch)
tree0f5ab699fdbe358b4d26e0800245171a4bc3478c
parentb9f36474e451b251a60e1f62fdd352e1bec73141 (diff)
downloadcdo-8206524ac2d1fa4a42d41c54ce59bdd07ccf8741.zip
cdo-8206524ac2d1fa4a42d41c54ce59bdd07ccf8741.tar.gz
cdo-8206524ac2d1fa4a42d41c54ce59bdd07ccf8741.tar.bz2
Fixed HeapOverflowException in ExtendedDataInputStream.readByteArray
-rw-r--r--plugins/org.eclipse.net4j/.options2
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/AbstractConnector.java3
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/BufferImpl.java2
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/Connector.java21
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/stream/ExtendedDataInputStream.java18
5 files changed, 31 insertions, 15 deletions
diff --git a/plugins/org.eclipse.net4j/.options b/plugins/org.eclipse.net4j/.options
index 2aa7225..d4803f3 100644
--- a/plugins/org.eclipse.net4j/.options
+++ b/plugins/org.eclipse.net4j/.options
@@ -7,7 +7,7 @@ org.eclipse.net4j/debug.registry = true
org.eclipse.net4j/debug.om = true
org.eclipse.net4j/debug.buffer = true
-org.eclipse.net4j/debug.buffer.stream = true
+org.eclipse.net4j/debug.buffer.stream = false
org.eclipse.net4j/debug.channel = true
org.eclipse.net4j/debug.selector = true
org.eclipse.net4j/debug.acceptor = true
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/AbstractConnector.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/AbstractConnector.java
index ac9ac92..acdc13c 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/AbstractConnector.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/AbstractConnector.java
@@ -616,7 +616,8 @@ public abstract class AbstractConnector extends AbstractLifecycle implements Con
super.onDeactivate();
}
- protected abstract void registerChannelWithPeer(short channelIndex, String protocolID) throws ConnectorException;
+ protected abstract void registerChannelWithPeer(short channelIndex, String protocolID)
+ throws ConnectorException;
private static int getNextConnectorID()
{
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/BufferImpl.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/BufferImpl.java
index bf06963..9f61513 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/BufferImpl.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/BufferImpl.java
@@ -296,7 +296,7 @@ public class BufferImpl implements Buffer
{
byteBuffer.flip();
}
-
+
if (state == State.PUTTING)
{
byteBuffer.position(HEADER_SIZE);
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/Connector.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/Connector.java
index 28bf96d..b21e3bd 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/Connector.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/Connector.java
@@ -22,15 +22,14 @@ import java.util.concurrent.ExecutorService;
* One endpoint of a physical connection of arbitrary nature between two
* communicating parties. A {@link Connector} encapsulates the process of
* establishing and closing such connections and has a {@link Type} of
- * {@link Type#CLIENT} or {@link Type#SERVER} with
- * respect to this process. Once a connection is established either party can
- * use its connector to open multiple {@link Channel}s to
- * asynchronously exchange {@link Buffer}s.
+ * {@link Type#CLIENT} or {@link Type#SERVER} with respect to this process. Once
+ * a connection is established either party can use its connector to open
+ * multiple {@link Channel}s to asynchronously exchange {@link Buffer}s.
* <p>
- * This interface is <b>not</b> intended to be implemented by clients. Providers of
- * connectors for new physical connection types have to subclass {@link AbstractConnector}
- * (see {@link ChannelImpl#setConnector(AbstractConnector)}.
- *
+ * This interface is <b>not</b> intended to be implemented by clients.
+ * Providers of connectors for new physical connection types have to subclass
+ * {@link AbstractConnector} (see
+ * {@link ChannelImpl#setConnector(AbstractConnector)}.
* <p>
*
* @author Eike Stepper
@@ -67,7 +66,8 @@ public interface Connector
public void connectAsync() throws ConnectorException;
/**
- * Blocks until <code>{@link #isConnected()} == true</code> or the given timeout expired.
+ * Blocks until <code>{@link #isConnected()} == true</code> or the given
+ * timeout expired.
* <p>
*
* @throws ConnectorException
@@ -76,7 +76,8 @@ public interface Connector
/**
* Synchronous connect. Blocks until <code>{@link #isConnected()} ==
- * true</code> or the given timeout expired.
+ * true</code>
+ * or the given timeout expired.
* <p>
*/
public boolean connect(long timeout) throws ConnectorException;
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/stream/ExtendedDataInputStream.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/stream/ExtendedDataInputStream.java
index 9814e3c..f2e5670 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/stream/ExtendedDataInputStream.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/stream/ExtendedDataInputStream.java
@@ -32,8 +32,22 @@ public class ExtendedDataInputStream extends DataInputStream implements Extended
throw new IndexOutOfBoundsException();
}
- byte[] b = new byte[length];
- read(b);
+ byte[] b;
+ try
+ {
+ b = new byte[length];
+ }
+ catch (Throwable t)
+ {
+ throw new IOException("Unable to allocate " + length + " bytes");
+ }
+
+ int bytes = read(b);
+ if (bytes != length)
+ {
+ throw new IOException("Unable to read " + length + " bytes (after " + bytes + " bytes)");
+ }
+
return b;
}