On Thu, 2009-06-04 at 16:43 +0100, Fabian Hugelshofer wrote:
> IPv6 knows scoped address types i.e. link and site local addresses. Link
> local addresses require a scope identifier to specify the interface/link
> an address is valid on (e.g. fe80::1%eth0). This scope identifier is
> only valid on a single node.
> 
> RFC 4007 says that the scope identifier shall not be sent across the
> wire, unless every node agrees on the semantics. Apache e.g. rejects
> HTTP requests with a scope identifier in the host header (see
> https://issues.apache.org/bugzilla/show_bug.cgi?id=35122).
> 
> This patch removes the scope identifier from the HTTP request, whereas
> it remains in the structure used to connect to the server. Please apply.

I did not get any feedback on this patch here. The Busybox maintainers
integrated my modifications into their tree (see commit
http://git.busybox.net/busybox/commit/?id=7d5ddf14a3ce2b9c3e8251e40d67333b13287a15).

I backported this commit for the current version of Busybox in OpenWRT.
Please apply.

Fabian

Index: package/busybox/patches/804-wget_no_ipv6_scope.patch
===================================================================
--- package/busybox/patches/804-wget_no_ipv6_scope.patch        (revision 0)
+++ package/busybox/patches/804-wget_no_ipv6_scope.patch        (revision 0)
@@ -0,0 +1,86 @@
+diff -ruN busybox-1.13.4.orig/networking/wget.c 
busybox-1.13.4/networking/wget.c
+--- busybox-1.13.4.orig/networking/wget.c      2009-07-01 10:35:39.000000000 
+0100
++++ busybox-1.13.4/networking/wget.c   2009-07-01 10:40:56.000000000 +0100
+@@ -193,6 +193,42 @@
+ #endif
+ 
+ 
++/* IPv6 knows scoped address types i.e. link and site local addresses. Link
++ * local addresses can have a scope identifier to specify the
++ * interface/link an address is valid on (e.g. fe80::1%eth0). This scope
++ * identifier is only valid on a single node.
++ *
++ * RFC 4007 says that the scope identifier MUST NOT be sent across the wire,
++ * unless all nodes agree on the semantic. Apache e.g. regards zone 
identifiers
++ * in the Host header as invalid requests, see
++ * https://issues.apache.org/bugzilla/show_bug.cgi?id=35122
++ */
++static void strip_ipv6_scope_id(char *host)
++{
++      char *scope, *cp;
++
++      /* bbox wget actually handles IPv6 addresses without [], like
++       * wget "http://::1/xxx";, but this is not standard.
++       * To save code, _here_ we do not support it. */
++
++      if (host[0] != '[')
++              return; /* not IPv6 */
++
++      scope = strchr(host, '%');
++      if (!scope)
++              return;
++
++      /* Remove the IPv6 zone identifier from the host address */
++      cp = strchr(host, ']');
++      if (!cp || (cp[1] != ':' && cp[1] != '\0')) {
++              /* malformed address (not "[xx]:nn" or "[xx]") */
++              return;
++      }
++
++      /* cp points to "]...", scope points to "%eth0]..." */
++      overlapping_strcpy(scope, cp);
++}
++
+ /* Read NMEMB bytes into PTR from STREAM.  Returns the number of bytes read,
+  * and a short count if an eof or non-interrupt error is encountered.  */
+ static size_t safe_fread(void *ptr, size_t nmemb, FILE *stream)
+@@ -483,18 +519,27 @@
+ #endif
+ 
+       parse_url(argv[optind], &target);
+-      server.host = target.host;
+-      server.port = target.port;
+ 
+       /* Use the proxy if necessary */
+       if (use_proxy) {
+               proxy = getenv(target.is_ftp ? "ftp_proxy" : "http_proxy");
+-              if (proxy && *proxy) {
++              if (proxy && proxy[0]) {
+                       parse_url(proxy, &server);
+               } else {
+                       use_proxy = 0;
+               }
+       }
++      if (!use_proxy) {
++              server.port = target.port;
++              if (ENABLE_FEATURE_IPV6) {
++                      server.host = xstrdup(target.host);
++              } else {
++                      server.host = target.host;
++              }
++      }
++
++      if (ENABLE_FEATURE_IPV6)
++              strip_ipv6_scope_id(target.host);
+ 
+       /* Guess an output filename, if there was no -O FILE */
+       if (!(opt & WGET_OPT_OUTNAME)) {
+@@ -674,6 +719,8 @@
+                                               parse_url(str, &target);
+                                               if (use_proxy == 0) {
+                                                       server.host = 
target.host;
++                                                      /* 
strip_ipv6_scope_id(target.host); - no! */
++                                                      /* we assume remote 
never gives us IPv6 addr with scope id */
+                                                       server.port = 
target.port;
+                                               }
+                                               free(lsa);


_______________________________________________
openwrt-devel mailing list
[email protected]
https://lists.openwrt.org/mailman/listinfo/openwrt-devel

Reply via email to