[jcifs] Bug in implementation of jcifs.smb.SmbFile#equals(Object).
Andreas Salathe
asal at zrh.che.xerox.com
Fri Feb 22 08:45:13 GMT 2008
Hi,
SmbFile.equals(Object o) just checks on the hashCode() for checking
equality and thus eventually
returns true, even if the compared SmbFile's are clearly distinct.
current impl: (jcifs_1.2.18, SmbFile.java)
public boolean equals( Object obj ) {
return obj instanceof SmbFile && obj.hashCode() == hashCode();
}
possible fixup:
public boolean equals( Object obj ) {
if (! ( obj instanceof SmbFile ))
return false;
SmbFile of = (SmbFile)obj;
String addr;
try {
addr = getAddress().toString(); }
catch (UnknownHostException uhe) {
addr = getServer().toUpperCase(); }
String oaddr;
try {
oaddr = of.getAddress().toString(); }
catch (UnknownHostException uhe) {
oaddr = of.getServer().toUpperCase(); }
if (!addr.equals(oaddr)) return false;
getUncPath0();
of.getUncPath0();
return canon.toUpperCase().equals(of.canon.toUpperCase());
}
More information about the jcifs
mailing list