Return-Path: Delivered-To: apmail-db-derby-dev-archive@www.apache.org Received: (qmail 23743 invoked from network); 3 Mar 2009 09:27:17 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 3 Mar 2009 09:27:17 -0000 Received: (qmail 62162 invoked by uid 500); 3 Mar 2009 09:27:17 -0000 Delivered-To: apmail-db-derby-dev-archive@db.apache.org Received: (qmail 62137 invoked by uid 500); 3 Mar 2009 09:27:17 -0000 Mailing-List: contact derby-dev-help@db.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: Delivered-To: mailing list derby-dev@db.apache.org Received: (qmail 62128 invoked by uid 99); 3 Mar 2009 09:27:17 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 03 Mar 2009 01:27:17 -0800 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.140] (HELO brutus.apache.org) (140.211.11.140) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 03 Mar 2009 09:27:16 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 3DC62234C4AE for ; Tue, 3 Mar 2009 01:26:56 -0800 (PST) Message-ID: <400610887.1236072416251.JavaMail.jira@brutus> Date: Tue, 3 Mar 2009 01:26:56 -0800 (PST) From: "Knut Anders Hatlen (JIRA)" To: derby-dev@db.apache.org Subject: [jira] Commented: (DERBY-4060) Blob.getBinaryStream(long,long) is off by one for the pos+len check In-Reply-To: <1706166888.1234821779809.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/DERBY-4060?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12678268#action_12678268 ] Knut Anders Hatlen commented on DERBY-4060: ------------------------------------------- Should we also update the javadoc comments in EmbedBlob and EmbedClob (they still say that we throw SQLException if pos+length is greater than the number of bytes/characters)? Same goes for the error message (XJ087.S) which says "Sum of position('{0}') and length('{1}') is greater than the size of the LOB." > 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.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 > > > 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.