[jcifs] Incorrect return from SmbFile.getUncPath()

dircha at bethel.edu dircha at bethel.edu
Tue Nov 12 20:07:28 EST 2002

>I am using jcifs-0.7.0b7.jar (and also found this error in 0b6).
>I use jcifs.smb.SmbFile.getUncPath() to create a corresponding java.io.File
>object. The problem is that in the return value the share name is dropped.
>Given an SmbFile constructed with this string:
>"smb://BG/SharedDocs/My Music/" where BG is a computer on the network,
>SmbFile.getUncPath() is returning "\\BG\My Music\".
>I believe the error is on line 689 of jcifs.smb.SmbFile.java in the
>getUncPath0() method. The share name is extracted to the member "share", but
>then the value assigned to the member "unc" begins at the '/' after the share
>name. The incorrect value in "unc" is then returned to the caller (getUncPath()).
>--Chad Dirks

Apologies, I should have tried the suggested solution before posting. Apparently
the purpose of getUntPath0() is different than I suspected, as making the
previously suggested change broke several other methods in the class. If the
behavior I described was incorrect, then I suspect that the same problem occurs
elsewhere in the class where the value of the member "unc" is used. If someone
can confirm that this behavior is incorrect, I will test additional methods.

At least for my immediate purposes however, the correct behavior can be had by
changing line 706 of jcifs.smb.SmbFile in the getUncPath() method from:
return "\\\\" + url.getHost() + getUncPath0()
return "\\\\" + url.getHost() + '\\' + share + getUncPath0()

--Chad Dirks

More information about the jcifs mailing list