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

From: <hno@dont-contact.us>
Date: Tue, 30 Oct 2001 15:20:15 +0100

Hmm.. this will also skip some invalid IPv6 addresses.. and thus we need
to still log the event at loglevel 1, which makes the whole idea of
patching only to get another message somewhat pointless I'd say.. but
other than this it looks good.

If the IPv6 detector could be fixed to only trigger on addresses that
very likely are IPv6 then we could consider changing the log level to 2,
which makes the patch quite appealing.

Regards
Henrik

Roger Venning wrote:

> 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 - 07:20:19 MST

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