diff options
author | Benoit Foucher <benoit@zeroc.com> | 2016-04-26 09:00:57 +0200 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2016-04-26 09:00:57 +0200 |
commit | c2ce37b7b0f6fc033cac4d52d460ee2f389d7737 (patch) | |
tree | dab204bc1dfd9298c7acb13b9493a210f8c4e978 /csharp | |
parent | Add jquery-cookie to bower dependency (diff) | |
download | ice-c2ce37b7b0f6fc033cac4d52d460ee2f389d7737.tar.bz2 ice-c2ce37b7b0f6fc033cac4d52d460ee2f389d7737.tar.xz ice-c2ce37b7b0f6fc033cac4d52d460ee2f389d7737.zip |
Fixed ICE-7115 - unmarshalling bug with optional parameters
Diffstat (limited to 'csharp')
-rw-r--r-- | csharp/src/Ice/BasicStream.cs | 21 | ||||
-rw-r--r-- | csharp/test/Ice/optional/AllTests.cs | 14 | ||||
-rw-r--r-- | csharp/test/Ice/optional/Test.ice | 4 | ||||
-rw-r--r-- | csharp/test/Ice/optional/TestAMD.ice | 4 | ||||
-rw-r--r-- | csharp/test/Ice/optional/TestAMDI.cs | 7 | ||||
-rw-r--r-- | csharp/test/Ice/optional/TestI.cs | 6 |
6 files changed, 49 insertions, 7 deletions
diff --git a/csharp/src/Ice/BasicStream.cs b/csharp/src/Ice/BasicStream.cs index cb36056533d..ab73ab83374 100644 --- a/csharp/src/Ice/BasicStream.cs +++ b/csharp/src/Ice/BasicStream.cs @@ -460,13 +460,30 @@ namespace IceInternal public Ice.EncodingVersion skipEmptyEncaps() { int sz = readInt(); - if(sz != 6) + if(sz < 6) { throw new Ice.EncapsulationException(); } + if(sz - 4 > _buf.b.remaining()) + { + throw new Ice.UnmarshalOutOfBoundsException(); + } Ice.EncodingVersion encoding = new Ice.EncodingVersion(); encoding.read__(this); + if(encoding.Equals(Ice.Util.Encoding_1_0)) + { + if(sz != 6) + { + throw new Ice.EncapsulationException(); + } + } + else + { + // Skip the optional content of the encapsulation if we are expecting an + // empty encapsulation. + _buf.b.position(_buf.b.position() + sz - 6); + } return encoding; } @@ -4380,7 +4397,7 @@ namespace IceInternal if(_current.sliceType == SliceType.ObjectSlice) { throw new Ice.NoObjectFactoryException("no object factory found and compact format prevents " + - "slicing (the sender should use the sliced format " + + "slicing (the sender should use the sliced format " + "instead)", _current.typeId); } else diff --git a/csharp/test/Ice/optional/AllTests.cs b/csharp/test/Ice/optional/AllTests.cs index d391ce340f2..5ede1eb40a4 100644 --- a/csharp/test/Ice/optional/AllTests.cs +++ b/csharp/test/Ice/optional/AllTests.cs @@ -444,7 +444,19 @@ public class AllTests : TestCommon.TestApp test(10 == g.gg2.a); test(20 == g.gg2Opt.Value.a); test("gg1".Equals(g.gg1.a)); - + + initial.opVoid(); + + os = Ice.Util.createOutputStream(communicator); + os.startEncapsulation(); + os.writeOptional(1, Ice.OptionalFormat.F4); + os.writeInt(15); + os.writeOptional(1, Ice.OptionalFormat.VSize); + os.writeString("test"); + os.endEncapsulation(); + inEncaps = os.finished(); + test(initial.ice_invoke("opVoid", Ice.OperationMode.Normal, inEncaps, out outEncaps)); + WriteLine("ok"); Write("testing marshaling of large containers with fixed size elements... "); diff --git a/csharp/test/Ice/optional/Test.ice b/csharp/test/Ice/optional/Test.ice index d4db71c76e1..99d1bc7558f 100644 --- a/csharp/test/Ice/optional/Test.ice +++ b/csharp/test/Ice/optional/Test.ice @@ -282,9 +282,11 @@ class Initial void sendOptionalClass(bool req, optional(1) OneOptional o); void returnOptionalClass(bool req, out optional(1) OneOptional o); - + G opG(G g); + void opVoid(); + bool supportsRequiredParams(); bool supportsJavaSerializable(); diff --git a/csharp/test/Ice/optional/TestAMD.ice b/csharp/test/Ice/optional/TestAMD.ice index a2d50d70352..e8e4fab4cb7 100644 --- a/csharp/test/Ice/optional/TestAMD.ice +++ b/csharp/test/Ice/optional/TestAMD.ice @@ -282,9 +282,11 @@ class Initial void sendOptionalClass(bool req, optional(1) OneOptional o); void returnOptionalClass(bool req, out optional(1) OneOptional o); - + G opG(G g); + void opVoid(); + bool supportsRequiredParams(); bool supportsJavaSerializable(); diff --git a/csharp/test/Ice/optional/TestAMDI.cs b/csharp/test/Ice/optional/TestAMDI.cs index 66aab304e71..05475175e1e 100644 --- a/csharp/test/Ice/optional/TestAMDI.cs +++ b/csharp/test/Ice/optional/TestAMDI.cs @@ -254,12 +254,17 @@ public class InitialI : Test.Initial { cb.ice_response(new Test.OneOptional(53)); } - + public override void opG_async(Test.AMD_Initial_opG cb, Test.G g, Ice.Current current) { cb.ice_response(g); } + public override void opVoid_async(Test.AMD_Initial_opVoid cb, Ice.Current current) + { + cb.ice_response(); + } + public override void supportsRequiredParams_async(Test.AMD_Initial_supportsRequiredParams cb, Ice.Current current) { cb.ice_response(false); diff --git a/csharp/test/Ice/optional/TestI.cs b/csharp/test/Ice/optional/TestI.cs index 10a2a08109a..13b3d59e8e1 100644 --- a/csharp/test/Ice/optional/TestI.cs +++ b/csharp/test/Ice/optional/TestI.cs @@ -291,12 +291,16 @@ public class InitialI : Test.Initial { o = new Test.OneOptional(53); } - + public override Test.G opG(Test.G g, Ice.Current current) { return g; } + public override void opVoid(Ice.Current current) + { + } + public override bool supportsRequiredParams(Ice.Current current) { return false; |