This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [Patch] PR java/22113: Fix buffer overflow in Java lexer forFP literals


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

According to Ranjit Mathew on 8/16/2005 12:34 PM:
>>What is the actual length of the longest of the tokens in question
>>allowed by the JLS?
> 

Literal token length is technically unlimited - the longest string
possible that still parses as a floating point number without causing
overflow or underflow must be parsed as such.  However, there IS a fixed
maximum length of significant characters at which the decision of which
exact 2's complement number the decimal string will round to (or can be
determined simply by scanning for the first non-zero digit after that
length); this limit is determined by the actual base-10 representation of
the 1ulp 2's complement denormal.  I wrote the jacks tests in question,
which purposefully use a 800+ character mantissa of the halfway point
between the smallest two denormals, as the longest string of non-zero
characters where rounding can make a difference.  I don't remember the
exact number of significant characters, but you can reverse engineer that
from the jacks test.  Remember that you need to strip leading zeros of
both the mantissa and exponent before starting to count characters towards
the limit; fortunately, Java has no way to stringize a literal so you only
need to obtain the exact value rather than preserve the original string.

On the other hand, since every possible double can be expressed with a
decimal string with a maximum of 24 characters (and even fewer characters
with hex-float literals in Java 1.5 syntax), only brain-dead compiler test
suites are ever likely to give you a literal with more than 256 characters :)

> 
> JLS 3.10.2 doesn't seem to specify token-length per se for FP literals:
> 
> http://java.sun.com/docs/books/jls/third_edition/html/lexical.html#3.10.2
> 
- --
Life is short - so eat dessert first!

Eric Blake             ebb9@byu.net
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFDAoQy84KuGfSFAYARAvhcAJ9M3cJKsTYZSjIY3uFFYWkUnLI7WwCfeuCT
mZgPOBxFu6SxZKHlPEM19Sk=
=t0bj
-----END PGP SIGNATURE-----


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]