[Soot-list] How verify array index value is within array bounds?

Patrick Lam plam at sable.mcgill.ca
Thu Jul 19 18:32:42 EDT 2012


On 07/19/12 18:27, John Dean wrote:
> Hello,
>
> I'm trying to verify that an array element access is safe in terms of
> the index being within the bounds of the array.
>
> In exploring the soot api, JArrayRef looks promising, with its getBase
> and getIndex methods. Is there a way to get the size of the array, so I
> can compare the index to it?
>
> Or is there a better way to solve my problem? I see that there are
> ArrayElement and ArrayBoundsChecker classes, but their methods don't
> look all that promising to me.

Soot is a static analysis framework: that is, it processes a Java 
program before the program executes. This means that it generally 
doesn't necessarily have the information that you might be hoping for. 
In particular, both array bounds and indexes can be hard to evaluate 
ahead of time. Researchers have written papers published in the 
literature describing conditions under which it is possible to ensure 
that array bounds checks are safe.  As one example, see "ABCD: 
eliminating array bounds checks on demand", by Bodik et al: 
http://dl.acm.org/citation.cfm?id=349342

pat


More information about the Soot-list mailing list