diff options
Diffstat (limited to 'cpp/include/Ice/InputStream.h')
-rw-r--r-- | cpp/include/Ice/InputStream.h | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/cpp/include/Ice/InputStream.h b/cpp/include/Ice/InputStream.h index 570564ef218..157da22b0fb 100644 --- a/cpp/include/Ice/InputStream.h +++ b/cpp/include/Ice/InputStream.h @@ -249,20 +249,31 @@ public: EncodingVersion skipEmptyEncapsulation() { - Int sz; + Ice::Int sz; read(sz); - if(sz != static_cast<Int>(sizeof(Int)) + 2) + if(sz < 6) { throwEncapsulationException(__FILE__, __LINE__); } - - if(i + 2 > b.end()) + if(i - sizeof(Ice::Int) + sz > b.end()) { throwUnmarshalOutOfBoundsException(__FILE__, __LINE__); } - - EncodingVersion encoding; + 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; } |