Return-Path: Delivered-To: apmail-db-derby-dev-archive@www.apache.org Received: (qmail 4216 invoked from network); 12 Apr 2009 11:33:37 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 12 Apr 2009 11:33:37 -0000 Received: (qmail 55419 invoked by uid 500); 12 Apr 2009 11:33:37 -0000 Delivered-To: apmail-db-derby-dev-archive@db.apache.org Received: (qmail 55368 invoked by uid 500); 12 Apr 2009 11:33:37 -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 55360 invoked by uid 99); 12 Apr 2009 11:33:36 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 12 Apr 2009 11:33:36 +0000 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; Sun, 12 Apr 2009 11:33:36 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id AA9E5234C041 for ; Sun, 12 Apr 2009 04:33:15 -0700 (PDT) Message-ID: <1375133476.1239535995692.JavaMail.jira@brutus> Date: Sun, 12 Apr 2009 04:33:15 -0700 (PDT) From: "Yun Lee (JIRA)" To: derby-dev@db.apache.org Subject: [jira] Updated: (DERBY-3941) Unsafe use of DataInput.skipBytes() in StoredPage and StoredFieldHeader In-Reply-To: <307633890.1226067287202.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/DERBY-3941?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Yun Lee updated DERBY-3941: --------------------------- Attachment: derby-3941-2.stat derby-3941-2.diff Knut, >1) skipPersistentDataInput() checks if DataInput.readByte() returns -1 to detect that EOF has been reached, but I think that that method will throw EOFException and not return -1 on EOF I have changed both skipPersistentDataInput() and skipPersistent() to perform like what you need, and changed the document of UTF8Util.internalSkip(final InputStream in, final long charsToSkip) which used the skipPersistent(). I think the new revision can act smartlier. Please check the new patches, thanks! >2) I think I would have renamed skipPersistentDataInput() and skipFullyDataInput() to skipPersistent() and skipFully(). I have tried this before providing the first patches, however, I found it's not able to use overload here, as it will lead to some compiling-time error on ambiguous use, i.e. InputStreamUtil.skipFully(null, int), and InputStreamUtil.skipFully(dis, int) where dis is an instance of DataInputStream. Yun > Unsafe use of DataInput.skipBytes() in StoredPage and StoredFieldHeader > ----------------------------------------------------------------------- > > Key: DERBY-3941 > URL: https://issues.apache.org/jira/browse/DERBY-3941 > Project: Derby > Issue Type: Bug > Components: Newcomer, Store > Reporter: Knut Anders Hatlen > Assignee: Yun Lee > Priority: Minor > Attachments: derby-3941-1.diff, derby-3941-1.stat, derby-3941-2.diff, derby-3941-2.stat > > > Some methods in StoredFileHeader and StoredPage call java.io.DataInput.skipBytes(int) with the assumption that it always skips the requested number of bytes. According to the javadoc for skipBytes, it may skip fewer bytes than requested, possibly 0, even if the end of the stream hasn't been reached. > The problem exists in these methods: > StoredFieldHeader.readFieldDataLength() > StoredPage.readRecordFromStream() > StoredPage.skipField() > StoredPage.readOneColumnFromPage() > StoredPage.readRecordFromArray() > We should change the code so that it works correctly even if skipBytes() were to skip fewer bytes than requested. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.