Re: ipcacheAddEntryFromHosts - problem with ip6 info in /etc/hosts

From: Roger Venning <r.venning@dont-contact.us>
Date: Tue, 30 Oct 2001 23:04:35 +1100

Robert Collins wrote:

>debian and other distro's these days are including ip6 info in
>/etc/hosts.
>
>Currently, HEAD spits the dummy:
>2001/10/30 00:19:59| ipcacheAddEntryFromHosts: bad IP address '::1'
>2001/10/30 00:19:59| ipcacheAddEntryFromHosts: bad IP address 'fe00::0'
>2001/10/30 00:19:59| ipcacheAddEntryFromHosts: bad IP address 'ff00::0'
>2001/10/30 00:19:59| ipcacheAddEntryFromHosts: bad IP address 'ff02::1'
>2001/10/30 00:19:59| ipcacheAddEntryFromHosts: bad IP address 'ff02::2'
>2001/10/30 00:19:59| ipcacheAddEntryFromHosts: bad IP address 'ff02::3'
>
>perhaps part of the IP6 branch could be used to allow this to be parsed
>and discarded?
>
>Rob
>
>
Here is an untested shot at fixing this for HEAD - it will detect and
print out a slightly different error message. The IPv6 branch already
has the capability to handle this; I'll change the message so that if it
is compiled without --enable-ipv6 that it prints out a message to the
effect that you need to compile with --enable-ipv6 to get IPv6 support.

Roger.

(does this apply? It is partially handcrafted as I don't have a clean
HEAD to diff against.)

diff -u ipcache.c.fake ipcache.c
--- ipcache.c.fake Sun Jun 17 13:43:52 2001
+++ ipcache.c Tue Oct 30 22:35:11 2001
@@ -845,14 +845,21 @@
  * adds a "static" entry from /etc/hosts.
  * returns 0 upon success, 1 if the ip address is invalid
  */
+#define V6ADDR "%[0123456789abcdefABCDEF.:]"
+
 int
 ipcacheAddEntryFromHosts(const char *name, const char *ipaddr)
 {
+ LOCAL_ARRAY(char, v6test, 256);
     ipcache_entry *i;
     struct in_addr ip;
     if (!safe_inet_addr(ipaddr, &ip)) {
- debug(14, 1) ("ipcacheAddEntryFromHosts: bad IP address '%s'\n",
- ipaddr);
+ if (strlen(ipaddr) <= MAXIPSTRLEN && sscanf(ipaddr, V6ADDR,
v6test) == 1)
+ debug(14, 1) ("ipcacheAddEntryFromHosts: this Squid does
not have IPv6 support - skipping '%s'\n",
+ ipaddr);
+ else
+ debug(14, 1) ("ipcacheAddEntryFromHosts: bad IP address '%s'\n",
+ ipaddr);
     return 1;
     }
     if ((i = ipcache_get(name))) {
Received on Tue Oct 30 2001 - 04:59:30 MST

This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:14:36 MST