Bug #6230 IndexOutOfBounds when reading BLOB with DataReader with GetString(index)
Submitted: 23 Oct 2004 18:30 Modified: 24 Oct 2004 3:03
Reporter: Levap Aretnyd Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / NET Severity:S2 (Serious)
Version:1.0.0 beta OS:Windows (Windows 2003)
Assigned to: Reggie Burnett CPU Architecture:Any

[23 Oct 2004 18: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 3: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