Issue with reading of data
--------------------------
Key: DNET-292
URL: http://tracker.firebirdsql.org/browse/DNET-292
Project: .NET Data provider
Issue Type: Bug
Components: ADO.NET Provider
Affects Versions: 2.5.1
Environment: Discovered using PocketPC running Windows CE over a LAN
link
Reporter: Russell Rose
Assignee: Jiri Cincura
The issue occurs within in XdrStream.cs and is specifically related to the
routines ReadInt32, ReadInt64 and ReadBytes(int count). None of these routines
compare the no of bytes read within the Read routine with the number of bytes
requested. This means that potentially the number of bytes requested do not
match the number of bytes delievered. I actually hit this issue during my
testing.
When speaking to Jiri, he suggested that I try the ReadByte() mechanism, but as
this can also return a -1, this return would also have to be tested to ensure
reliability. Given below are my suggested changes that seem to sort out my
problem
public byte[] ReadBytes(int count)
{
return this.ReadOpaque(count, false);
}
public byte[] ReadOpaque(int length)
{
return this.ReadOpaque(length, true);
}
public byte[] ReadOpaque(int length,Boolean pad)
{
byte[] buffer = new byte[length];
int readed = 0;
if (length > 0)
{
while (readed < length)
{
readed += this.Read(buffer, readed, length - readed);
}
// Add padding if required
int padLength = ((4 - length) & 3);
if (padLength > 0 && pad)
{
this.Read(Pad, 0, padLength);
}
}
return buffer;
}
public int ReadInt32()
{
return
IPAddress.HostToNetworkOrder(BitConverter.ToInt32(ReadOpaque(4,false), 0));
}
public long ReadInt64()
{
return
IPAddress.HostToNetworkOrder(BitConverter.ToInt64(ReadOpaque(8,false), 0));
}
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://tracker.firebirdsql.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
Firebird-net-provider mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/firebird-net-provider