[18525] in cryptography@c2.net mail archive

home help back first fref pref prev next nref lref last post

Re: Java: Helping the world build bigger idiots

daemon@ATHENA.MIT.EDU (Bill Frantz)
Tue Sep 20 17:28:57 2005

X-Original-To: cryptography@metzdowd.com
X-Original-To: cryptography@metzdowd.com
Date: Mon, 19 Sep 2005 16:45:20 -0700
From: Bill Frantz <frantz@pwpconsult.com>
To: cryptography@metzdowd.com
In-Reply-To: <E1EHJxx-0006SI-00@medusa01.cs.auckland.ac.nz>

On 9/19/05, pgut001@cs.auckland.ac.nz (Peter Gutmann) wrote:

>Found on the Daily WTF, http://www.thedailywtf.com/forums/43223/ShowPost.a=
spx:
>
>  try {=20
>    int idx =3D 0;=20
>   =20
>    while (true) {=20
>      displayProductInfo(prodnums[idx]);
>      idx++;=20
>      }=20
>    }=20
>  catch (IndexOutOfBoundException ex) {=20
>    // nil
>    }

This is obviously just an attempt to make Java array access more like Java =
file access.  :-)

Seriously, the real flaw in this approach, which I did not see mentioned in=
 the comments on the web page Peter references above, is the masking of Ind=
exOutOfBoundExceptions that may be generated by displayProductInfo.  This c=
ode will treat such errors as "end of array".  A more normal coding of the =
loop:

    for (int i=3D1; i<prodnums.length; i++) {=20
      displayProductInfo(prodnums[idx]);
      idx++;=20
    }=20

would let the exception pass up the call chain, and with good error handlin=
g, the problem would come to the attention of those responsible for fixing =
the program.

If ArrayIndexOutOfBoundException were used instead of IndexOutOfBoundExcept=
ion, errors in string indexing would pass up the call chain, while catching=
 array problems.


Cheers - Bill

---------------------------------------------------------------------
Bill Frantz        | The first thing you need   | Periwinkle=20
(408)356-8506      | when using a perimeter     | 16345 Englewood Ave
www.pwpconsult.com | defense is a perimeter.    | Los Gatos, CA 95032

---------------------------------------------------------------------
The Cryptography Mailing List
Unsubscribe by sending "unsubscribe cryptography" to majordomo@metzdowd.com

home help back first fref pref prev next nref lref last post