Re: rfc2732 patch for wget

2003-09-09 Thread Hrvoje Niksic
Mauro Tortonesi [EMAIL PROTECTED] writes:

 On Mon, 8 Sep 2003, Post, Mark K wrote:

 Absolutely.  I would much rather get an intelligent error message
 stating that ipv6 addresses are not supported, versus a misleading
 one about the host not being found.  That would save end-users a
 whole lot of wasted time.

 i agree here.

OK then.  Here is an additional patch:

2003-09-09  Hrvoje Niksic  [EMAIL PROTECTED]

* url.c (url_parse): Return an error if the URL contains a [...]
IPv6 numeric address and we don't support IPv6.

Index: src/url.c
===
RCS file: /pack/anoncvs/wget/src/url.c,v
retrieving revision 1.77
diff -u -r1.77 url.c
--- src/url.c   2003/09/05 20:36:17 1.77
+++ src/url.c   2003/09/09 13:02:46
@@ -649,7 +649,9 @@
   Invalid user name,
 #define PE_UNTERMINATED_IPV6_ADDRESS   5
   Unterminated IPv6 numeric address,
-#define PE_INVALID_IPV6_ADDRESS6
+#define PE_IPV6_NOT_SUPPORTED  6
+  IPv6 addresses not supported,
+#define PE_INVALID_IPV6_ADDRESS7
   Invalid IPv6 numeric address
 };
 
@@ -658,6 +660,7 @@
 *(p) = (v);\
 } while (0)
 
+#ifdef INET6
 /* The following two functions were adapted from glibc. */
 
 static int
@@ -787,8 +790,8 @@
 
   return 1;
 }
+#endif
 
-
 /* Parse a URL.
 
Return a new struct url if successful, NULL on error.  In case of
@@ -860,6 +863,7 @@
  return NULL;
}
 
+#ifdef INET6
   /* Check if the IPv6 address is valid. */
   if (!is_valid_ipv6_address(host_b, host_e))
{
@@ -869,6 +873,10 @@
 
   /* Continue parsing after the closing ']'. */
   p = host_e + 1;
+#else
+  SETERR (error, PE_IPV6_NOT_SUPPORTED);
+  return NULL;
+#endif
 }
   else
 {


RE: rfc2732 patch for wget

2003-09-08 Thread Post, Mark K
Absolutely.  I would much rather get an intelligent error message stating
that ipv6 addresses are not supported, versus a misleading one about the
host not being found.  That would save end-users a whole lot of wasted time.


Mark Post

-Original Message-
From: Hrvoje Niksic [mailto:[EMAIL PROTECTED]
Sent: Friday, September 05, 2003 4:23 PM
To: Mauro Tortonesi
Cc: [EMAIL PROTECTED]
Subject: Re: rfc2732 patch for wget


-snip-
I'm starting to think that Wget should reject all [...] addresses
when IPv6 is not compiled in because they, being valid IPv6 addresses,
have no chance of ever working.  What do you think?


Re: rfc2732 patch for wget

2003-09-07 Thread Hrvoje Niksic
Mauro Tortonesi [EMAIL PROTECTED] writes:

 here is my rfc2732 patch for wget. here is a brief summary of the
 changes i've made:
[...]

Thanks for the patch.  I'm about to apply this, with several (minor)
changes:

* I modified the functions to not require a zero-terminated string,
  but to accept an END argument instead.  That game url_parse doesn't
  need to play games with terminating the string and then restoring
  the old char.

* I changed boolean to int in accordance with (most of) the rest of
  Wget.

* I removed the `assert' you added in case of overflow.  I don't have
  anything against asserts, but they should be used to test internal
  logic of the code, not to verify user input!  I hate programs that
  coredump on me for giving them input they don't like.

  If you want to check for overflow, do so, but then have the function
  return an error.

Also, there's an issue I'm not sure how to handle.  If Wget is not
compiled with IPv6 support, it accepts the IPv6 addresses, but then
barfs.  For example:

$ ./wget 'http://[this-address-sucks]/'
http://[this-address-sucks]/: Invalid IPv6 numeric address.

So far so good.  But:

$ ./wget 'http://[3ffe:501::::123.4.5.6]/'
--22:20:04--  http://[3ffe:501::::123.4.5.6]/
   = `index.html'
Resolving 3ffe:501::::123.4.5.6... failed: Host not found.

And even:

$ ./wget 'http://[::127.0.0.1]/'
--22:16:26--  http://[::127.0.0.1]/
   = `index.html'
Resolving ::127.0.0.1... failed: Host not found.

I'm starting to think that Wget should reject all [...] addresses
when IPv6 is not compiled in because they, being valid IPv6 addresses,
have no chance of ever working.  What do you think?