This project has moved and is read-only. For the latest updates, please go here.

bug in Payload.cs

Jan 28, 2011 at 7:41 PM
Edited Jan 28, 2011 at 7:42 PM


there is a static method called "AddHeader" in the class "TVA.Communication.Payload"

the first line of the code allocates memory buffer, but with a wrong size, the original code is

byte[] result = new byte[(length - offset) + marker.Length + LengthSegment];

this line of code will allocate insufficient memory when the "offset" is non-zero, which will cause "System.ArgumentException : Offset and length were out of bounds for the array or count is greater than the number of elements from index to the end of the source collection. ".

The bug has been proved by unit test.

the correct code should be:

byte[] result = new byte[length + marker.Length + LengthSegment];

Hopefully, it will help to improve openPDC.


Jan 31, 2011 at 12:44 PM
Edited Jan 31, 2011 at 12:45 PM

This has been fixed in the TVA Code Library - we will roll down the new dependencies which will include this fix:

Thanks for the catch!

From: Pinal Patel
Sent: Sunday, January 30, 2011 10:37 AM
To: Ritchie Carroll
Subject: RE: bug in Payload.cs [openpdc:243722]

Good catch...fix checked in. Bug that was result of a bug fix.

From: ritchiecarroll
To: pinal.patel
Subject: FW: bug in Payload.cs [openpdc:243722]
Date: Fri, 28 Jan 2011 15:53:47 -0500

FYI - possible bug fix for communications library...