[jcifs] Bug in JCIFS-0.7.0b12
MaWaismann at ifsc.de
MaWaismann at ifsc.de
Wed Jan 8 20:43:04 EST 2003
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