summaryrefslogtreecommitdiff
path: root/cpp/include
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/include')
-rw-r--r--cpp/include/Ice/BasicStream.h19
1 files changed, 15 insertions, 4 deletions
diff --git a/cpp/include/Ice/BasicStream.h b/cpp/include/Ice/BasicStream.h
index da2ffde4a7f..0650e0971df 100644
--- a/cpp/include/Ice/BasicStream.h
+++ b/cpp/include/Ice/BasicStream.h
@@ -271,18 +271,29 @@ public:
{
Ice::Int sz;
read(sz);
- if(sz != static_cast<Ice::Int>(sizeof(Ice::Int)) + 2)
+ if(sz < 6)
{
throwEncapsulationException(__FILE__, __LINE__);
}
-
- if(i + 2 > b.end())
+ if(i - sizeof(Ice::Int) + sz > b.end())
{
throwUnmarshalOutOfBoundsException(__FILE__, __LINE__);
}
-
Ice::EncodingVersion encoding;
read(encoding);
+ if(encoding == Ice::Encoding_1_0)
+ {
+ if(sz != static_cast<Ice::Int>(sizeof(Ice::Int)) + 2)
+ {
+ throwEncapsulationException(__FILE__, __LINE__);
+ }
+ }
+ else
+ {
+ // Skip the optional content of the encapsulation if we are expecting an
+ // empty encapsulation.
+ i += sz - sizeof(Ice::Int) - 2;
+ }
return encoding;
}
void endReadEncapsChecked(); // Used by public stream API.