Bug #6230 IndexOutOfBounds when reading BLOB with DataReader with GetString(index)
Submitted: 23 Oct 2004 20:30 Modified: 24 Oct 2004 5:03
Reporter: Levap Aretnyd
Status: Closed
Category:Connector/Net Severity:S2 (Serious)
Version:1.0.0 beta OS:Microsoft Windows (Windows 2003)
Assigned to: Reggie Burnett Target Version:

[23 Oct 2004 20:30] Levap Aretnyd
Description:
There is a IndexOutOfBounds exception when reading BLOB columns with MySqlDataReader as
strings with MySqlDataReader.GetString(index). Exception occures in
MySqlBinary.ToString(). Method uses index and length variables to locate subset of a byte
buffer. Other methods such as ToBytes() are ignoring these values and using whole buffer.

How to repeat:
see description

Suggested fix:
Use whole buffer for string conversion, since indexes are not valid.
Replace line 57 in mysqlbinary.cs, containing statement:
    return encoding.GetString( (byte[])mValue, (int)index, (int)length );
with:
    return encoding.GetString((byte[])mValue);
[24 Oct 2004 5:03] Reggie Burnett
Thank you for your bug report. This issue has been committed to our
source repository of that product and will be incorporated into the
next release.

If necessary, you can access the source repository and build the latest
available version, including the bugfix, yourself. More information 
about accessing the source trees is available at
    http://www.mysql.com/doc/en/Installing_source_tree.html