You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-dev@db.apache.org by "Kristian Waagan (JIRA)" <ji...@apache.org> on 2009/03/09 10:55:50 UTC

[jira] Resolved: (DERBY-4060) Blob.getBinaryStream(long,long) is off by one for the pos+len check

     [ https://issues.apache.org/jira/browse/DERBY-4060?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Kristian Waagan resolved DERBY-4060.
------------------------------------

    Resolution: Fixed
    Derby Info:   (was: [Patch Available])

Committed patch 2a to trunk with revision 751637.
Backported to 10.4 and 10.3 with revisions 751639 and 751640.

This concludes my work on this issue.

> Blob.getBinaryStream(long,long) is off by one for the pos+len check
> -------------------------------------------------------------------
>
>                 Key: DERBY-4060
>                 URL: https://issues.apache.org/jira/browse/DERBY-4060
>             Project: Derby
>          Issue Type: Bug
>          Components: JDBC, Network Client
>    Affects Versions: 10.3.3.1, 10.4.2.0, 10.5.0.0
>            Reporter: Trejkaz
>            Assignee: Kristian Waagan
>             Fix For: 10.3.3.1, 10.4.2.1, 10.5.0.0
>
>         Attachments: derby-4060-1a-sub_stream_fix.diff, derby-4060-1a-sub_stream_fix.stat, derby-4060-1b-sub_stream_fix.diff, derby-4060-2a-doc_changes.diff
>
>
> If you have a BLOB of length 20, and call blob.getBinaryStream(11,10), it will give you an error:
>     java.sql.SQLException: Sum of position('11') and length('10') is greater than the size of the LOB.
> This is following word for word an error in the JDBC Javadoc:
>         SQLException - if pos is less than 1 or if pos is greater than the number of bytes in the Blob or if pos + length is greater than the number of bytes in the Blob
> So it's checking 11 + 10 > 20, but it should check 11 + 10 > 21    (pos + len > blob.length() + 1) to allow reading the last byte.
> The Javadoc for Clob.getCharacterStream(long,long) has similar wording so it may have the same issue.
> Likewise, the client driver may have the same issue -- I haven't yet checked.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.