#18 Incorrect byte length for JIMarshalUnMarshalHelper$ShortImpl

open
nobody
None
5
2012-11-29
2011-10-04
Morten Andersen
No

Incorrect byte length for JIMarshalUnMarshalHelper$ShortImpl SerializerDeserializer - is (2 + 2), should be 2

Keywords: Writing VT_I2 array, exception code 0x800706F7

Short summary: The SerializerDeserializer for Short (VT_I2) returns 4 as the element size in getLengthInBytes(). This should be 2.

Patch attached. Line 744 in JIMarshalUnMarshalHelper (SVN revision @136)

Long explaination:

When sending a VT_I2 array (size 480) to my COM server, my call fails with the following error:

[code]
org.jinterop.dcom.common.JIException: The stub received bad data. Please check whether the API has been called in the right way, with correct parameter formation. [0x800706F7]
at org.jinterop.dcom.core.JIComServer.call(JIComServer.java:963)
at org.jinterop.dcom.core.JIComServer.call(JIComServer.java:914)
at org.jinterop.dcom.core.JIComObjectImpl.call(JIComObjectImpl.java:268)
at org.jinterop.dcom.core.JIComObjectImpl.call(JIComObjectImpl.java:155)
..
..
Caused by: rpc.FaultException: Received fault. (unknown)
at rpc.ConnectionOrientedEndpoint.call(ConnectionOrientedEndpoint.java:141)
at rpc.Stub.call(Stub.java:113)
at org.jinterop.dcom.core.JIComServer.call(JIComServer.java:959)
... 35 more
[/code]

After debugging on this and observing the trace output, I found that the JIMarshalUnMarshalHelper$ShortImpl#getLengthInBytes() returns "2 + 2". When changing this to plain 2 (as would be obvious for Short, and also matches the size used in NdrBuffer#enc_ndr_short/dec_ndr_short) my call succeds.

Below is package trace for both the error and the ok scenario:

First the error:
[code]
FINEST: Variant length is 1028 , value 129 , variant type2
Oct 3, 2011 4:26:39 PM rpc.ConnectionOrientedEndpoint call
FINEST:
00000: 05 00 02 00 00 00 00 00 00 00 00 00 00 05 09 EA |...............ê|
00010: D9 EE 10 C0 8C B5 A4 05 83 E0 66 E3 00 00 00 00 |Ùî.À.µ¤..àfã....|
00020: 01 00 00 00 01 00 00 00 B0 00 0B 01 01 00 00 00 |........°.......|
00030: 55 73 65 72 00 00 00 00 81 00 00 00 00 00 00 00 |User............|
00040: 02 20 CC CC CC CC CC CC 00 20 00 00 BB CD EB 62 |. ÌÌÌÌÌÌ. ..»Íëb|
00050: 01 00 00 00 01 00 00 00 01 00 80 00 04 00 00 00 |................|
00060: 00 00 02 00 02 00 00 00 E0 01 00 00 68 8A 9A 64 |........à...h..d|
00070: E0 01 00 00 00 00 00 00 E0 01 00 00 00 00 00 00 |à.......à.......|
.....
00440: 00 00 00 00 00 00 00 00 00 00 00 00 |............ |
[/code]

And then after the change:
[code]
FINEST: Variant length is 1028 , value 129 , variant type2
Oct 3, 2011 4:25:04 PM rpc.ConnectionOrientedEndpoint call
FINEST:
00000: 05 00 02 00 00 00 00 00 00 00 00 00 00 05 09 EA |...............ê|
00010: D4 3E 10 20 83 5B AC 38 A2 E8 9C F0 00 00 00 00 |Ô>. .[¬8¢è.ð....|
00020: 01 00 00 00 01 00 00 00 B0 00 0B 01 01 00 00 00 |........°.......|
00030: 55 73 65 72 00 00 00 00 81 00 00 00 00 00 00 00 |User............|
00040: 02 20 CC CC CC CC CC CC 00 20 00 00 DE E7 83 59 |. ÌÌÌÌÌÌ. ..Þç.Y|
00050: 01 00 00 00 01 00 00 00 01 00 80 00 02 00 00 00 |................|
00060: 00 00 02 00 02 00 00 00 E0 01 00 00 B7 5B E3 7A |........à...·[ãz|
00070: E0 01 00 00 00 00 00 00 E0 01 00 00 00 00 00 00 |à.......à.......|
.....
00440: 00 00 00 00 00 00 00 00 00 00 00 00 |............ |
[/code]

The change (besides the different pointer values) is in position 0x5C where 04 is changed to 02.

Without knowing the details of the DCE packages I assume that this value tells the server the size of each element in the array. And this value being incorrect makes the server return the above error.

The original code did not seem to have any ill effect when sending individual VT_I2 values, but only when sending array values.

Best Regards
Morten

Discussion

  • patch for JIMarshalUnMarshalHelper

     
    Attachments