Return-Path: Delivered-To: apmail-myfaces-dev-archive@www.apache.org Received: (qmail 32991 invoked from network); 27 Sep 2010 06:15:02 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 27 Sep 2010 06:15:02 -0000 Received: (qmail 58482 invoked by uid 500); 27 Sep 2010 06:15:02 -0000 Delivered-To: apmail-myfaces-dev-archive@myfaces.apache.org Received: (qmail 58063 invoked by uid 500); 27 Sep 2010 06:14:58 -0000 Mailing-List: contact dev-help@myfaces.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "MyFaces Development" Delivered-To: mailing list dev@myfaces.apache.org Received: (qmail 58047 invoked by uid 99); 27 Sep 2010 06:14:57 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 27 Sep 2010 06:14:57 +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.22] (HELO thor.apache.org) (140.211.11.22) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 27 Sep 2010 06:14:55 +0000 Received: from thor (localhost [127.0.0.1]) by thor.apache.org (8.13.8+Sun/8.13.8) with ESMTP id o8R6EXEG026135 for ; Mon, 27 Sep 2010 06:14:33 GMT Message-ID: <15647666.415411285568073842.JavaMail.jira@thor> Date: Mon, 27 Sep 2010 02:14:33 -0400 (EDT) From: "Christian Kaltepoth (JIRA)" To: dev@myfaces.apache.org Subject: [jira] Updated: (MYFACES-2930) ClassByteCodeAnnotationFilter doesn't read the constants pool correctly In-Reply-To: <20879372.415391285568073557.JavaMail.jira@thor> 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/MYFACES-2930?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Christian Kaltepoth updated MYFACES-2930: ----------------------------------------- Status: Patch Available (was: Open) > ClassByteCodeAnnotationFilter doesn't read the constants pool correctly > ----------------------------------------------------------------------- > > Key: MYFACES-2930 > URL: https://issues.apache.org/jira/browse/MYFACES-2930 > Project: MyFaces Core > Issue Type: Bug > Components: General > Affects Versions: 2.0.3-SNAPSHOT > Reporter: Christian Kaltepoth > Priority: Minor > Attachments: MYFACES-2930.patch > > > The ClassByteCodeAnnotationFilter used to check classes for annotations by reading their bytecode doesn't read the constants pool table correctly. > The current code reads the number of entries from the class file and then reads each entry in the pool in a "for" loop. Unfortunately the code fails to process entries of the type "CONSTANT_Long" and "CONSTANT_Double" correctly. The Java VM spec says: > "All 8-byte constants take up two entries in the constant_pool table of the class file. If a CONSTANT_Long_info or CONSTANT_Double_info structure is the item in the constant_pool table at index n, then the next usable item in the pool is located at index n+2. The constant_pool index n+1 must be valid but is considered unusable." > From: http://java.sun.com/docs/books/jvms/second_edition/html/ClassFile.doc.html#1348 > The ClassByteCodeAnnotationFilter doesn't increase the loop counter for these entry types. Thus the filter will read bytes outside of the constants pool as soon as it finds a double or long constant in the constants pool because it will try to read more entries than there actually are. > Please note that this doesn't lead to faulty behavior of the class, because if the reader reaches the end of the constants pool, it didn't find any reference until then and therefore it is OK to abort scanning and return "false". > Find attached a patch containing a fix for this issue and a small unit test for the ClassByteCodeAnnotationFilter. I also added a log statement to default block of the switch statement. I guess this wasn't done because the current implementation often found bad tag values because of this bug. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.