summaryrefslogtreecommitdiff
path: root/cpp/src/Ice/BasicStream.cpp
diff options
context:
space:
mode:
authorMarc Laukien <marc@zeroc.com>2002-06-18 17:04:03 +0000
committerMarc Laukien <marc@zeroc.com>2002-06-18 17:04:03 +0000
commit3ded1c27abc7aecf5ddcf7b1f649ce17fd71bc89 (patch)
tree91c69af8acfa522a6e96961a4017bd91bcfc3ea7 /cpp/src/Ice/BasicStream.cpp
parentfile IcePackAdmin.py was initially added on branch location. (diff)
downloadice-3ded1c27abc7aecf5ddcf7b1f649ce17fd71bc89.tar.bz2
ice-3ded1c27abc7aecf5ddcf7b1f649ce17fd71bc89.tar.xz
ice-3ded1c27abc7aecf5ddcf7b1f649ce17fd71bc89.zip
exception fix
Diffstat (limited to 'cpp/src/Ice/BasicStream.cpp')
-rw-r--r--cpp/src/Ice/BasicStream.cpp33
1 files changed, 32 insertions, 1 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);
}
}