diff options
Diffstat (limited to 'java/src/IceInternal/BasicStream.java')
-rw-r--r-- | java/src/IceInternal/BasicStream.java | 50 |
1 files changed, 37 insertions, 13 deletions
diff --git a/java/src/IceInternal/BasicStream.java b/java/src/IceInternal/BasicStream.java index 16409506b80..f55c45b7669 100644 --- a/java/src/IceInternal/BasicStream.java +++ b/java/src/IceInternal/BasicStream.java @@ -422,15 +422,27 @@ public class BasicStream endReadEncaps() { assert(_readEncapsStack != null); - int start = _readEncapsStack.start; - int sz = _readEncapsStack.sz; - try - { - _buf.b.position(start + sz); - } - catch(IllegalArgumentException ex) + if(_buf.b.position() != _readEncapsStack.start + _readEncapsStack.sz) { - throw new Ice.UnmarshalOutOfBoundsException(); + if(_buf.b.position() + 1 != _readEncapsStack.start + _readEncapsStack.sz) + { + throw new Ice.EncapsulationException(); + } + + // + // Ice version < 3.3 had a bug where user exceptions with + // class members could be encoded with a trailing byte + // when dispatched with AMD. So we tolerate an extra byte + // in the encapsulation. + // + try + { + _buf.b.get(); + } + catch(java.nio.BufferUnderflowException ex) + { + throw new Ice.UnmarshalOutOfBoundsException(); + } } ReadEncaps curr = _readEncapsStack; @@ -441,15 +453,27 @@ public class BasicStream } public void - checkReadEncaps() + skipEmptyEncaps() { - assert(_readEncapsStack != null); - int start = _readEncapsStack.start; - int sz = _readEncapsStack.sz; - if(_buf.b.position() != start + sz) + int sz = readInt(); + if(sz < 0) + { + throw new Ice.NegativeSizeException(); + } + + if(sz != 6) { throw new Ice.EncapsulationException(); } + + try + { + _buf.b.position(_buf.b.position() + 2); + } + catch(IllegalArgumentException ex) + { + throw new Ice.UnmarshalOutOfBoundsException(); + } } public int |