summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/Ice/BasicStream.cpp33
-rw-r--r--cpp/src/Ice/Exception.cpp79
2 files changed, 75 insertions, 37 deletions
diff --git a/cpp/src/Ice/BasicStream.cpp b/cpp/src/Ice/BasicStream.cpp
index eb986ba3ff5..a960f1d27d8 100644
--- a/cpp/src/Ice/BasicStream.cpp
+++ b/cpp/src/Ice/BasicStream.cpp
@@ -112,7 +112,18 @@ IceInternal::BasicStream::startReadEncaps()
throw UnsupportedEncodingException(__FILE__, __LINE__);
}
Int sz;
+ //
+ // I don't use readSize() and writeSize() for encapsulations,
+ // because when creating an encapsulation, I must know in advance
+ // how many bytes the size information will require in the data
+ // stream. If I use an Int, it is always 4 bytes. For
+ // readSize()/writeSize(), it could be 1 or 5 bytes.
+ //
read(sz);
+ if (sz < 0)
+ {
+ throw NegativeSizeException(__FILE__, __LINE__);
+ }
_readEncapsStack.resize(_readEncapsStack.size() + 1);
_currentReadEncaps = &_readEncapsStack.back();
_currentReadEncaps->encoding = encoding;
@@ -136,6 +147,10 @@ IceInternal::BasicStream::endReadEncaps()
i = b.begin() + start - sizeof(Int);
Int sz;
read(sz);
+ if (sz < 0)
+ {
+ throw NegativeSizeException(__FILE__, __LINE__);
+ }
i += sz;
if (i > b.end())
{
@@ -152,6 +167,10 @@ IceInternal::BasicStream::checkReadEncaps()
i = b.begin() + start - sizeof(Int);
Int sz;
read(sz);
+ if (sz < 0)
+ {
+ throw NegativeSizeException(__FILE__, __LINE__);
+ }
i = save;
if (sz != i - (b.begin() + start))
{
@@ -168,6 +187,10 @@ IceInternal::BasicStream::getReadEncapsSize()
i = b.begin() + start - sizeof(Int);
Int sz;
read(sz);
+ if (sz < 0)
+ {
+ throw NegativeSizeException(__FILE__, __LINE__);
+ }
i = save;
return sz;
}
@@ -183,6 +206,10 @@ IceInternal::BasicStream::skipEncaps()
}
Int sz;
read(sz);
+ if (sz < 0)
+ {
+ throw NegativeSizeException(__FILE__, __LINE__);
+ }
i += sz;
if (i > b.end())
{
@@ -212,10 +239,14 @@ IceInternal::BasicStream::readSize(Ice::Int& v)
if (b < 0)
{
read(v);
+ if (v < 0)
+ {
+ throw NegativeSizeException(__FILE__, __LINE__);
+ }
}
else
{
- v = static_cast<Int>(b);
+ v = static_cast<Int>(b);
}
}
diff --git a/cpp/src/Ice/Exception.cpp b/cpp/src/Ice/Exception.cpp
index 37582d7c2b4..ae8b67ffaaf 100644
--- a/cpp/src/Ice/Exception.cpp
+++ b/cpp/src/Ice/Exception.cpp
@@ -191,129 +191,136 @@ Ice::ProtocolException::ice_print(ostream& out) const
}
void
-Ice::UnmarshalException::ice_print(ostream& out) const
+Ice::UnsupportedProtocolException::ice_print(ostream& out) const
{
Exception::ice_print(out);
- out << ":\nprotocol error: error during unmarshaling";
+ out << ":\nprotocol error: unsupported protocol version";
}
void
-Ice::UnmarshalOutOfBoundsException::ice_print(ostream& out) const
+Ice::UnsupportedEncodingException::ice_print(ostream& out) const
{
Exception::ice_print(out);
- out << ":\nprotocol error: out of bounds during unmarshaling";
+ out << ":\nprotocol error: unsupported encoding version";
}
void
-Ice::NoObjectFactoryException::ice_print(ostream& out) const
+Ice::UnknownMessageException::ice_print(ostream& out) const
{
Exception::ice_print(out);
- out << ":\nprotocol error: no suitable object factory found";
+ out << ":\nprotocol error: unknown message type";
}
void
-Ice::NoUserExceptionFactoryException::ice_print(ostream& out) const
+Ice::UnknownRequestIdException::ice_print(ostream& out) const
{
Exception::ice_print(out);
- out << ":\nprotocol error: no suitable user exception factory found";
+ out << ":\nprotocol error: unknown request id";
}
void
-Ice::ProxyUnmarshalException::ice_print(ostream& out) const
+Ice::UnknownReplyStatusException::ice_print(ostream& out) const
{
Exception::ice_print(out);
- out << ":\nprotocol error: inconsistent proxy data during unmarshaling";
+ out << ":\nprotocol error: unknown reply status";
}
void
-Ice::IllegalIndirectionException::ice_print(ostream& out) const
+Ice::CloseConnectionException::ice_print(ostream& out) const
{
Exception::ice_print(out);
- out << ":\nprotocol error: encountered illegal protocol indirection";
+ out << ":\nprotocol error: connection closed";
}
void
-Ice::MemoryLimitException::ice_print(ostream& out) const
+Ice::AbortBatchRequestException::ice_print(ostream& out) const
{
Exception::ice_print(out);
- out << ":\nprotocol error: memory limit exceeded";
+ out << ":\nprotocol error: batch request was aborted";
}
void
-Ice::EncapsulationException::ice_print(ostream& out) const
+Ice::IllegalMessageSizeException::ice_print(ostream& out) const
{
Exception::ice_print(out);
- out << ":\nprotocol error: illegal encapsulation";
+ out << ":\nprotocol error: illegal message size";
}
void
-Ice::UnsupportedProtocolException::ice_print(ostream& out) const
+Ice::CompressionNotSupportedException::ice_print(ostream& out) const
{
Exception::ice_print(out);
- out << ":\nprotocol error: unsupported protocol version";
+ out << ":\nprotocol error: compressed messages not supported";
}
void
-Ice::UnsupportedEncodingException::ice_print(ostream& out) const
+Ice::CompressionException::ice_print(ostream& out) const
{
Exception::ice_print(out);
- out << ":\nprotocol error: unsupported encoding version";
+ out << ":\nprotocol error: failed to compress or uncompress data";
}
void
-Ice::UnknownMessageException::ice_print(ostream& out) const
+Ice::MarshalException::ice_print(ostream& out) const
{
Exception::ice_print(out);
- out << ":\nprotocol error: unknown message type";
+ out << ":\nprotocol error: error during unmarshaling";
}
void
-Ice::UnknownRequestIdException::ice_print(ostream& out) const
+Ice::NoObjectFactoryException::ice_print(ostream& out) const
{
Exception::ice_print(out);
- out << ":\nprotocol error: unknown request id";
+ out << ":\nprotocol error: no suitable object factory found";
}
void
-Ice::UnknownReplyStatusException::ice_print(ostream& out) const
+Ice::NoUserExceptionFactoryException::ice_print(ostream& out) const
{
Exception::ice_print(out);
- out << ":\nprotocol error: unknown reply status";
+ out << ":\nprotocol error: no suitable user exception factory found";
}
void
-Ice::CloseConnectionException::ice_print(ostream& out) const
+Ice::UnmarshalOutOfBoundsException::ice_print(ostream& out) const
{
Exception::ice_print(out);
- out << ":\nprotocol error: connection closed";
+ out << ":\nprotocol error: out of bounds during unmarshaling";
}
void
-Ice::AbortBatchRequestException::ice_print(ostream& out) const
+Ice::ProxyUnmarshalException::ice_print(ostream& out) const
{
Exception::ice_print(out);
- out << ":\nprotocol error: batch request was aborted";
+ out << ":\nprotocol error: inconsistent proxy data during unmarshaling";
}
void
-Ice::IllegalMessageSizeException::ice_print(ostream& out) const
+Ice::IllegalIndirectionException::ice_print(ostream& out) const
{
Exception::ice_print(out);
- out << ":\nprotocol error: illegal message size";
+ out << ":\nprotocol error: encountered illegal protocol indirection";
}
void
-Ice::CompressionNotSupportedException::ice_print(ostream& out) const
+Ice::MemoryLimitException::ice_print(ostream& out) const
{
Exception::ice_print(out);
- out << ":\nprotocol error: compressed messages not supported";
+ out << ":\nprotocol error: memory limit exceeded";
}
void
-Ice::CompressionException::ice_print(ostream& out) const
+Ice::EncapsulationException::ice_print(ostream& out) const
{
Exception::ice_print(out);
- out << ":\nprotocol error: failed to compress or uncompress data";
+ out << ":\nprotocol error: illegal encapsulation";
+}
+
+void
+Ice::NegativeSizeException::ice_print(ostream& out) const
+{
+ Exception::ice_print(out);
+ out << ":\nprotocol error: negative size for sequence, dictionary, etc.";
}
void