[jcifs] jcifs bug

Michael B.Allen mballen at erols.com
Sat Mar 23 10:46:14 EST 2002

On Fri, 22 Mar 2002 16:16:34 -0700
"Bernie Wieser" <bernie.wieser at calgary.qcdata.com> wrote:

> Yes, but even that is dangerous!  Take the following....
> URL u = new URL( "smb://host/...")
> it will call parse right?  what if host isn't known?  then
> parse consumes the exception, does not set u, so u is bogus.

Not bogus but malformed. If you run a simple test you get:

Exception in thread "main" java.net.MalformedURLException: smb:, null
        at jcifs.smb.SmbURL.parseSmbURL(SmbURL.java:223)
        at jcifs.smb.SmbFile.<init>(SmbFile.java:385)
        at jcifs.smb.SmbFile.<init>(SmbFile.java:338)
        at jcifs.smb.Handler.openConnection(Handler.java:29)
        at java.net.URL.openConnection(URL.java:781)
        at java.net.URL.openStream(URL.java:798)
        at GetURL.main(GetURL.java:30)

I think that should be ok but I don't know how it will perform when
stressed. Again, the SMB Protocol handler has not been thoroughly
tested/explored (that's why I'm so glad to see you using it the way
you are).

> On the one hand, the cached info would yield a corrupt url,
> and in the new version, an unknown host or other exception
> will yield an uninitialized url, so...
> Someone (Me?) needs to write parse url so it doesn't actually
> try to do anything (i.e. nmblookup).  All it must do is scan...
> To solve our current problem, I end up rethrowing the smb exception
> as a runtime exception in parse (evil hack until fixed).

There's a noteworthy problem here. The jCIFS SMB URL is based on an IETF
draft that requires the authority component to be resolved *during the
parse* in order to determine if it's a servername like:


or a workgroup name:


You can see this URL is "overloaded". So a query (actually two concurrent
queries) must go out on the wire. Otherwise there would be no reason to
go out on the wire; name resolution could be handled lazily.


Are you even considering the:


format suggested by the other URL IETF people?


> B.
> -----Original Message-----
> From: Michael B. Allen [mailto:mballen at erols.com]
> Sent: Friday, March 22, 2002 4:16 PM
> To: Bernie Wieser
> Subject: Re: [jcifs] jcifs bug
> You had it in the try/catch in your code. I'm following you man :~)
> On Fri, 22 Mar 2002 16:05:09 -0700
> "Bernie Wieser" <bernie.wieser at calgary.qcdata.com> wrote:
> > 
> > Another bug that you've fixed...
> > 
> > By moving setUrl inside the try/catch block, process will no longer
> > call setUrl with cached file information (so ie UnknownHost will not set
> > the URL to the wrong thing.)   We just bumped into this one.
> > 
> > B.

May The Source be with you.

More information about the jcifs mailing list