[jcifs] Bug in SmbFile.getName() ??

Mario Matzulla mario.melanie at arcor.de
Tue Dec 4 07:43:52 GMT 2007

Hi Mike,

first of all, I want to thank you for your effort you put into this project. I'm also an open source dev and I know how hard this sometimes can be. Keep up with the great work!! :)

Now let me describe me problem:
We are using the jCIFS lib to build a web-based fileexplorer. During testing, we found out, that you can create files with a leading or ending whitespace. But when asking for the name of such a file, we get a trimmed name, which we can't use for any operation anymore :(

During debugging I think I found out why this is happening:
When creating a SmbFile, you are handing over the name (including whitespaces) and initializing some variables. The name gets trimmed in the URL class, expanded and assigned to the local vars cannon and url (not the same values, but trimmed). The only var which gets assigned the real name (plus "\\") is unc. Now when calling the getName() function you are first checking the getUncPath0(), but since the unc is not null, nothing happens there and if, you would still use the url to initialize cannon, share and unc.
Afterwards you are using the cannon string to find out about the name, but this string has been trimmed before :(

My suggestion would be to use the unc in getName() to figure out the name. Or, store the name in a local var and return it in getName() :)

Mario Matzulla

Viel oder wenig? Schnell oder langsam? Unbegrenzt surfen + telefonieren
ohne Zeit- und Volumenbegrenzung? DAS TOP ANGEBOT FÜR ALLE NEUEINSTEIGER
Jetzt bei Arcor: günstig und schnell mit DSL - das All-Inclusive-Paket
für clevere Doppel-Sparer, nur  29,95 €  inkl. DSL- und ISDN-Grundgebühr!

More information about the jcifs mailing list