[jcifs] Bug in JCIFS-0.7.0b12

Allen, Michael B (RSCH) Michael_B_Allen at ml.com
Thu Jan 9 12:13:13 EST 2003


Indeed. The i variable should not have been incremented when the token "DNS" is
encountered. This was never reported previously probably because jCIFS uses
UniAddress almost exclusively and it has it's own resolveOrder code that does
know about "DNS".

> -----Original Message-----
> From:	MaWaismann at ifsc.de [SMTP:MaWaismann at ifsc.de]
> Sent:	Wednesday, January 08, 2003 4:43 AM
> To:	jcifs at samba.org
> Subject:	[jcifs] Bug in JCIFS-0.7.0b12
> 
> Dear Mr. Allen,
> 
> using your library jcifs-0.7.0b12 I encountered a possible bug in the class
> jcifs.netbios.NameServiceClient. There are the following code lines in the
> constructor to initialize the resolve order:
> 
> 
>             int[] tmp = new int[3];
>             StringTokenizer st = new StringTokenizer( ro, "," );
>             int i = 0;
>             while( st.hasMoreTokens() ) {
>                 String s = st.nextToken().trim();
>                 if( s.equalsIgnoreCase( "LMHOSTS" )) {
>                     tmp[i++] = RESOLVER_LMHOSTS;
>                 } else if( s.equalsIgnoreCase( "WINS" )) {
>                     if( nbns == null ) {
>                         Log.println( Log.WARNINGS, "netbios name service
> warning",
>                                 " resolveOrder specifies WINS however the "
> +
>                                 "jcifs.netbios.wins property has not been
> set" );
>                         continue;
>                     }
>                     tmp[i++] = RESOLVER_WINS;
>                 } else if( s.equalsIgnoreCase( "BCAST" )) {
>                     tmp[i++] = RESOLVER_BCAST;
>                 } else if( s.equalsIgnoreCase( "DNS" )) {
>                     i++; // skip
>                 } else {
>                     Log.println( Log.WARNINGS, "netbios name service
> warning",
>                                 "unknown resolver method: " + s );
>                 }
>             }
>             resolveOrder = new int[i];
>             System.arraycopy( tmp, 0, resolveOrder, 0, i );
> 
> 
> In the case of setting up the property
> jcifs.resolveOrder=LMHOSTS,WINS,BCAST,DNS, the while loop is going through
> four times. If the property jcifs.netbios.wins is set too, i has the value 4
> at the end of the while loop.
> 
> Therefore the method System.arraycopy is called with the parameter (tmp[3],
> 0, resolveOrder, 0, 4) and throws the
> java.lang.ArrayIndexOutOfBoundsException, because the length of the array
> tmp is 3 instead of 4.
> 
> If the token is "DNS" in the while loop, i should not be incremented. 
> 
> 
> Yours sincerely,
> Marco Waismann
> ifsc informationservices gmbh
> email: MaWaismann at ifsc.de
> 




More information about the jcifs mailing list