Author: nick Date: Thu Mar 1 07:59:56 2007 New Revision: 513391 URL: http://svn.apache.org/viewvc?view=rev&rev=513391 Log: If the username length in the CurrentUserAtom is clearly wrong, treat it as if there was no username, rather than giving an ArrayIndexOutOfBoundsException
Modified: jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/CurrentUserAtom.java Modified: jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/CurrentUserAtom.java URL: http://svn.apache.org/viewvc/jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/CurrentUserAtom.java?view=diff&rev=513391&r1=513390&r2=513391 ============================================================================== --- jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/CurrentUserAtom.java (original) +++ jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/CurrentUserAtom.java Thu Mar 1 07:59:56 2007 @@ -135,9 +135,20 @@ // Get the username length long usernameLen = LittleEndian.getUShort(_contents,20); + if(usernameLen > 512) { + // Handle the case of it being garbage + System.err.println("Warning - invalid username length " + usernameLen + " found, treating as if there was no username set"); + usernameLen = 0; + } - // Use this to grab the revision - releaseVersion = LittleEndian.getUInt(_contents,28+(int)usernameLen); + // Now we know the length of the username, + // use this to grab the revision + if(_contents.length >= 28+(int)usernameLen + 4) { + releaseVersion = LittleEndian.getUInt(_contents,28+(int)usernameLen); + } else { + // No revision given, as not enough data. Odd + releaseVersion = 0; + } // Grab the unicode username, if stored int start = 28+(int)usernameLen+4; --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] Mailing List: http://jakarta.apache.org/site/mail2.html#poi The Apache Jakarta POI Project: http://jakarta.apache.org/poi/