|
Re: Problem with jcifs.UniAddress.isValidDnsName(String): msg#00049network.samba.java
On Fri, 7 Oct 2005 16:11:58 -0400 Michael B Allen <mba2000@xxxxxxxxxx> wrote: > On Fri, 7 Oct 2005 14:37:20 -0400 > Michael B Allen <mba2000@xxxxxxxxxx> wrote: > > > > I'm wondering if the method actually serves any purpose except to be > > > broken. Its only reference is: > > > > > > if( isValidDnsName( hostname ) == false ) { > > > throw new UnknownHostException( hostname ); > > > } > > > addr = InetAddress.getByName( hostname ); > > > > > > Consider that InetAddress.getByName(hostname) throws the same > > > UnknownHostException as the 'if' statement, and is more effective at > > > detecting invalid hostnames than any method call or regex. Could the > > > method and call be removed entirely? > > > > Clearly this check is designed to subvert the DNS lookup because > > it may *succeed* and then the resolver will not try the next lookup > > method. Unfortunately I don't understand the code comment and I don't > > recall what the original problem was. > > I just remembered why this is in here. You can have a NetBIOS hostname > like '1' and I *think* InetAddress.getByName() would incorrectly interpret > this as an IP address and NOT throw an UnknownHostException (at the time > I checked, probably Java 1.2 days). So this code tried to dodge this > in the case where resolvOrder had DNS before NBT. Otherwise getByName > would return a bogus InetAddress and the loop would not continue on to > try NbtAddress.getByName(). > > So it's Sun's fault not me! I believe I've fixed this. I have replaced isValidDnsName with a method isAllDigits so that if the supplied name contains only digits it will not be resolved with DNS. Also, I have verified that Java 1.4 still exhibits the same behavior of successfully resolving a name that contains only digits (e.g. 111222 yields 111222/0.1.178.118). Mike |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | RE: Struts forwards and jCIFS NTLM: 00049, Justin Mahoney |
|---|---|
| Next by Date: | Re: LARGE_READX / LARGE_WRITEX support: 00049, Michael B Allen |
| Previous by Thread: | Newbie questioni: 00049, jonathan . lister |
| Next by Thread: | Re: LARGE_READX / LARGE_WRITEX support: 00049, Michael B Allen |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |