[jcifs] URLHandler Bug
Allen, Michael B (RSCH)
Michael_B_Allen at ml.com
Thu Sep 26 11:53:53 EST 2002
Damn. That's 3 bugs. I'll fix these now. Pls hold.
> -----Original Message-----
> From: Thomas Krammer [SMTP:TKrammer at nxn-software.com]
> Sent: Wednesday, September 25, 2002 9:47 PM
> To: 'jcifs at samba.org'
> Subject: [jcifs] URLHandler Bug
>
> Hi everyone,
>
> I'm writing an application which supports various file transfer protocols. The file's location is represented by an URL. First I parse the URL using java.net.URL and then trigger protocol specific
> behavior. Using this application I found a bug in jcifs.smb.Handler.
>
> The jcifs.smb.Handler class stores a SmbFile object used to parse the URL. If any error occrs during the URL parsing that object isn't overwritten. So when a incorrect SMB URL (e.g. containing an
> invalid host name) is used to create an URL object the last valid parsing result is used.
>
> The example code below demonstrates this problem.
>
>
> Thomas
>
>
> ======================================================
> Code
> ======================================================
>
> import java.io.*;
> import java.net.*;
>
> import jcifs.smb.*;
>
> public class URLTest
> {
> public URLTest()
> {
> }
>
> public static void main(String args[])
> {
> try {
> Class.forName("jcifs.Config");
>
> // This host exists
> URL correctURL = new URL("smb://mellotron");
>
> // This host doesn't exist
> URL wrongURL = new URL("smb://a_non_existing_machine");
>
> System.out.println("Correct URL "+correctURL.toString());
> System.out.println("Wrong URL "+wrongURL.toString());
> }
> catch(Exception e) {
> System.out.println("EXCEPTION");
> }
> }
> }
>
> ===================================================
> Output
> ===================================================
>
> Sep 26 03:11:11.852 - smb URLStreamHandler exception
> java.net.UnknownHostException: a_non_existing_machine
> at jcifs.UniAddress.getByName(UniAddress.java:268)
> at jcifs.smb.SmbURL.parseSmbURL(SmbURL.java:80)
> at jcifs.smb.SmbFile.<init>(SmbFile.java:413)
> at jcifs.smb.Handler.parseURL(Handler.java:35)
> at java.net.URL.<init>(URL.java:608)
> at java.net.URL.<init>(URL.java:476)
> at java.net.URL.<init>(URL.java:425)
> at performance.URLTest.main(URLTest.java:27)
> Correct URL smb://mellotron
> Wrong URL smb://mellotron
>
>
More information about the jcifs
mailing list