summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenoit Foucher <benoit@zeroc.com>2019-10-02 19:21:07 +0200
committerBenoit Foucher <benoit@zeroc.com>2019-10-02 19:21:07 +0200
commit8fb855336e8f2fdf319c56253fb063f57346e8ad (patch)
treed87f11865f60178470fe107df05c60a88d5e6ad3
parentConditional compilation of TCP transport with Swift builds (diff)
downloadice-8fb855336e8f2fdf319c56253fb063f57346e8ad.tar.bz2
ice-8fb855336e8f2fdf319c56253fb063f57346e8ad.tar.xz
ice-8fb855336e8f2fdf319c56253fb063f57346e8ad.zip
The Ice connection will now print warnings for first invalid messages received by a client, fixes #565
-rw-r--r--cpp/src/Ice/ConnectionI.cpp22
-rw-r--r--csharp/src/Ice/ConnectionI.cs22
-rw-r--r--java-compat/src/Ice/src/main/java/Ice/ConnectionI.java22
-rw-r--r--java/src/Ice/src/main/java/com/zeroc/Ice/ConnectionI.java22
-rw-r--r--js/src/Ice/ConnectionI.js21
5 files changed, 60 insertions, 49 deletions
diff --git a/cpp/src/Ice/ConnectionI.cpp b/cpp/src/Ice/ConnectionI.cpp
index 413a5d8775f..9fa189e089f 100644
--- a/cpp/src/Ice/ConnectionI.cpp
+++ b/cpp/src/Ice/ConnectionI.cpp
@@ -1650,6 +1650,15 @@ Ice::ConnectionI::message(ThreadPoolCurrent& current)
_observer->receivedBytes(static_cast<int>(headerSize));
}
+ //
+ // Connection is validated on first message. This is only used by
+ // setState() to check wether or not we can print a connection
+ // warning (a client might close the connection forcefully if the
+ // connection isn't validated, we don't want to print a warning
+ // in this case).
+ //
+ _validated = true;
+
ptrdiff_t pos = _readStream.i - _readStream.b.begin();
if(pos < headerSize)
{
@@ -1683,6 +1692,7 @@ Ice::ConnectionI::message(ThreadPoolCurrent& current)
{
throw IllegalMessageSizeException(__FILE__, __LINE__);
}
+
if(size > static_cast<Int>(_messageSizeMax))
{
Ex::throwMemoryLimitException(__FILE__, __LINE__, static_cast<size_t>(size), _messageSizeMax);
@@ -2737,6 +2747,8 @@ Ice::ConnectionI::validate(SocketOperation operation)
_observer.finishRead(_readStream);
}
+ _validated = true;
+
assert(_readStream.i == _readStream.b.end());
_readStream.i = _readStream.b.begin();
Byte m[4];
@@ -2769,8 +2781,6 @@ Ice::ConnectionI::validate(SocketOperation operation)
throw IllegalMessageSizeException(__FILE__, __LINE__);
}
traceRecv(_readStream, _logger, _traceLevels);
-
- _validated = true;
}
}
@@ -3243,14 +3253,6 @@ Ice::ConnectionI::parseMessage(InputStream& stream, Int& invokeNum, Int& request
assert(stream.i == stream.b.end());
- //
- // Connection is validated on first message. This is only used by
- // setState() to check wether or not we can print a connection
- // warning (a client might close the connection forcefully if the
- // connection isn't validated).
- //
- _validated = true;
-
try
{
//
diff --git a/csharp/src/Ice/ConnectionI.cs b/csharp/src/Ice/ConnectionI.cs
index 318fe77c562..81c4b9f6f98 100644
--- a/csharp/src/Ice/ConnectionI.cs
+++ b/csharp/src/Ice/ConnectionI.cs
@@ -1216,6 +1216,15 @@ namespace Ice
_observer.receivedBytes(Protocol.headerSize);
}
+ //
+ // Connection is validated on first message. This is only used by
+ // setState() to check wether or not we can print a connection
+ // warning (a client might close the connection forcefully if the
+ // connection isn't validated, we don't want to print a warning
+ // in this case).
+ //
+ _validated = true;
+
int pos = _readStream.pos();
if(pos < Protocol.headerSize)
{
@@ -1253,6 +1262,7 @@ namespace Ice
{
throw new IllegalMessageSizeException();
}
+
if(size > _messageSizeMax)
{
Ex.throwMemoryLimitException(size, _messageSizeMax);
@@ -2256,6 +2266,8 @@ namespace Ice
observerFinishRead(_readStream.getBuffer());
}
+ _validated = true;
+
Debug.Assert(_readStream.pos() == Protocol.headerSize);
_readStream.pos(0);
byte[] m = _readStream.readBlob(4);
@@ -2287,8 +2299,6 @@ namespace Ice
throw new IllegalMessageSizeException();
}
TraceUtil.traceRecv(_readStream, _logger, _traceLevels);
-
- _validated = true;
}
}
@@ -2579,14 +2589,6 @@ namespace Ice
Debug.Assert(info.stream.pos() == info.stream.size());
- //
- // Connection is validated on first message. This is only used by
- // setState() to check wether or not we can print a connection
- // warning (a client might close the connection forcefully if the
- // connection isn't validated).
- //
- _validated = true;
-
try
{
//
diff --git a/java-compat/src/Ice/src/main/java/Ice/ConnectionI.java b/java-compat/src/Ice/src/main/java/Ice/ConnectionI.java
index 85d7b141361..bd4879c1ed9 100644
--- a/java-compat/src/Ice/src/main/java/Ice/ConnectionI.java
+++ b/java-compat/src/Ice/src/main/java/Ice/ConnectionI.java
@@ -1138,6 +1138,16 @@ public final class ConnectionI extends IceInternal.EventHandler
{
throw new Ice.IllegalMessageSizeException();
}
+
+ //
+ // Connection is validated on first message. This is only used by
+ // setState() to check wether or not we can print a connection
+ // warning (a client might close the connection forcefully if the
+ // connection isn't validated, we don't want to print a warning
+ // in this case).
+ //
+ _validated = true;
+
if(size > _messageSizeMax)
{
IceInternal.Ex.throwMemoryLimitException(size, _messageSizeMax);
@@ -2283,6 +2293,8 @@ public final class ConnectionI extends IceInternal.EventHandler
observerFinishRead(_readStream.getBuffer());
}
+ _validated = true;
+
assert (_readStream.pos() == IceInternal.Protocol.headerSize);
_readStream.pos(0);
byte[] m = _readStream.readBlob(4);
@@ -2313,8 +2325,6 @@ public final class ConnectionI extends IceInternal.EventHandler
throw new IllegalMessageSizeException();
}
IceInternal.TraceUtil.traceRecv(_readStream, _logger, _traceLevels);
-
- _validated = true;
}
}
@@ -2613,14 +2623,6 @@ public final class ConnectionI extends IceInternal.EventHandler
assert (info.stream.pos() == info.stream.size());
- //
- // Connection is validated on first message. This is only used by
- // setState() to check wether or not we can print a connection
- // warning (a client might close the connection forcefully if the
- // connection isn't validated).
- //
- _validated = true;
-
try
{
//
diff --git a/java/src/Ice/src/main/java/com/zeroc/Ice/ConnectionI.java b/java/src/Ice/src/main/java/com/zeroc/Ice/ConnectionI.java
index 5b3fd3292ce..55edfa597f5 100644
--- a/java/src/Ice/src/main/java/com/zeroc/Ice/ConnectionI.java
+++ b/java/src/Ice/src/main/java/com/zeroc/Ice/ConnectionI.java
@@ -1007,6 +1007,15 @@ public final class ConnectionI extends com.zeroc.IceInternal.EventHandler
_observer.receivedBytes(Protocol.headerSize);
}
+ //
+ // Connection is validated on first message. This is only used by
+ // setState() to check wether or not we can print a connection
+ // warning (a client might close the connection forcefully if the
+ // connection isn't validated, we don't want to print a warning
+ // in this case).
+ //
+ _validated = true;
+
int pos = _readStream.pos();
if(pos < Protocol.headerSize)
{
@@ -1045,6 +1054,7 @@ public final class ConnectionI extends com.zeroc.IceInternal.EventHandler
{
throw new IllegalMessageSizeException();
}
+
if(size > _messageSizeMax)
{
com.zeroc.IceInternal.Ex.throwMemoryLimitException(size, _messageSizeMax);
@@ -2195,6 +2205,8 @@ public final class ConnectionI extends com.zeroc.IceInternal.EventHandler
observerFinishRead(_readStream.getBuffer());
}
+ _validated = true;
+
assert (_readStream.pos() == Protocol.headerSize);
_readStream.pos(0);
byte[] m = _readStream.readBlob(4);
@@ -2225,8 +2237,6 @@ public final class ConnectionI extends com.zeroc.IceInternal.EventHandler
throw new IllegalMessageSizeException();
}
TraceUtil.traceRecv(_readStream, _logger, _traceLevels);
-
- _validated = true;
}
}
@@ -2521,14 +2531,6 @@ public final class ConnectionI extends com.zeroc.IceInternal.EventHandler
assert (info.stream.pos() == info.stream.size());
- //
- // Connection is validated on first message. This is only used by
- // setState() to check wether or not we can print a connection
- // warning (a client might close the connection forcefully if the
- // connection isn't validated).
- //
- _validated = true;
-
try
{
//
diff --git a/js/src/Ice/ConnectionI.js b/js/src/Ice/ConnectionI.js
index 26721eed259..15347c08b67 100644
--- a/js/src/Ice/ConnectionI.js
+++ b/js/src/Ice/ConnectionI.js
@@ -748,6 +748,15 @@ class ConnectionI
Debug.assert(this._readStream.buffer.remaining === 0);
this._readHeader = false;
+ //
+ // Connection is validated on first message. This is only used by
+ // setState() to check wether or not we can print a connection
+ // warning (a client might close the connection forcefully if the
+ // connection isn't validated, we don't want to print a warning
+ // in this case).
+ //
+ this._validated = true;
+
const pos = this._readStream.pos;
if(pos < Protocol.headerSize)
{
@@ -781,6 +790,7 @@ class ConnectionI
{
throw new Ice.IllegalMessageSizeException();
}
+
if(size > this._messageSizeMax)
{
ExUtil.throwMemoryLimitException(size, this._messageSizeMax);
@@ -1550,6 +1560,8 @@ class ConnectionI
return false;
}
+ this._validated = true;
+
Debug.assert(this._readStream.pos === Protocol.headerSize);
this._readStream.pos = 0;
const m = this._readStream.readBlob(4);
@@ -1576,7 +1588,6 @@ class ConnectionI
throw new Ice.IllegalMessageSizeException();
}
TraceUtil.traceRecv(this._readStream, this._logger, this._traceLevels);
- this._validated = true;
}
}
@@ -1756,14 +1767,6 @@ class ConnectionI
this._readStream.pos = 0;
this._readHeader = true;
- //
- // Connection is validated on first message. This is only used by
- // setState() to check wether or not we can print a connection
- // warning (a client might close the connection forcefully if the
- // connection isn't validated).
- //
- this._validated = true;
-
Debug.assert(info.stream.pos === info.stream.size);
try