[jcifs] StringIndexOutOfBoundsException from SmbFile.java

Gary Rambo c-grambo at aventail.com
Tue Oct 7 07:13:46 EST 2003


I'm getting a StringIndexOutOfBoundsException from SmbFile.java from a 
ListFiles query with the smb url "smb://":

java -cp ../../jcifs-0.7.13.jar:. ListFiles smb://
Exception in thread "main" java.lang.StringIndexOutOfBoundsException: 
String index out of range: -1
       at java.lang.String.charAt(String.java:444)
       at jcifs.smb.SmbFile.<init>(SmbFile.java:503)
       at jcifs.smb.SmbFile.listFiles(SmbFile.java:1357)
       at jcifs.smb.SmbFile.listFiles(SmbFile.java:1303)
       at ListFiles.main(ListFiles.java:13)

A charAt() operation looking for a trailing '/' on a negative index is 
the culprit and I've attached the simple fix.

Note there are two other charAt()s in SmbFile.java looking for the same 
trailing '/', but I haven't encountered problems with those.

Gary

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smbfile.zip
Type: application/zip
Size: 15438 bytes
Desc: not available
Url : http://lists.samba.org/archive/jcifs/attachments/20031006/ef299716/smbfile.zip


More information about the jcifs mailing list