diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2023-11-17 20:23:56 +0000 |
---|---|---|
committer | Laurent Bercot <ska@appnovation.com> | 2023-11-17 20:23:56 +0000 |
commit | d06529686f89074fd4fa574ac6012f8a873e7857 (patch) | |
tree | e2fd4e499d8a633feeff288a9d42e904abca8903 /src/libs6dns/s6dns_hosts_compile.c | |
parent | 9d432bd8a07dd36247339c40fa6bf2719600fdb2 (diff) | |
download | s6-dns-d06529686f89074fd4fa574ac6012f8a873e7857.tar.xz |
Prepare for 2.3.7.0; ignore link-local addresses in /etc/hosts
Signed-off-by: Laurent Bercot <ska@appnovation.com>
Diffstat (limited to 'src/libs6dns/s6dns_hosts_compile.c')
-rw-r--r-- | src/libs6dns/s6dns_hosts_compile.c | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/src/libs6dns/s6dns_hosts_compile.c b/src/libs6dns/s6dns_hosts_compile.c index b57ffd3..0d537d7 100644 --- a/src/libs6dns/s6dns_hosts_compile.c +++ b/src/libs6dns/s6dns_hosts_compile.c @@ -144,20 +144,20 @@ static void *byipv6_dtok (uint32_t d, void *aux) static inline uint8_t cclass (char c) { - static uint8_t const ctable[128] = "09999999913111999999999999999999199299999999945977777777776999999888888888888888888888888889999898888888888888888888888888899999" ; + static uint8_t const ctable[128] = "0999999991311199999999999999999919929:999999945977777777776999999888888888888888888888888889999898888888888888888888888888899999" ; return c & 0x80 ? 9 : ctable[(uint8_t)c] - '0' ; } static int s6dns_hosts_parse (buffer *b, hostdata *hd) { - static uint8_t const table[6][10] = + static uint8_t const table[6][11] = { - { 0x0a, 0x00, 0x01, 0x00, 0x0b, 0x0b, 0x12, 0x12, 0x12, 0x0b }, - { 0x0a, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 }, - { 0x2a, 0x23, 0x0b, 0x20, 0x0b, 0x12, 0x12, 0x12, 0x12, 0x0b }, - { 0x0a, 0x03, 0x01, 0x00, 0x0b, 0x0b, 0x0b, 0x0b, 0x14, 0x0b }, - { 0x4a, 0xc4, 0x0b, 0x40, 0x14, 0x14, 0x0b, 0x14, 0x14, 0x0b }, - { 0x0a, 0x05, 0x01, 0x00, 0x0b, 0x0b, 0x0b, 0x0b, 0x14, 0x0b } + { 0x0a, 0x00, 0x01, 0x00, 0x0b, 0x0b, 0x12, 0x12, 0x12, 0x0b, 0x0b }, + { 0x0a, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 }, + { 0x2a, 0x23, 0x0b, 0x20, 0x0b, 0x12, 0x12, 0x12, 0x12, 0x0b, 0x21 }, + { 0x0a, 0x03, 0x01, 0x00, 0x0b, 0x0b, 0x0b, 0x0b, 0x14, 0x0b, 0x0b }, + { 0x4a, 0xc4, 0x0b, 0x40, 0x14, 0x14, 0x0b, 0x14, 0x14, 0x0b, 0x0b }, + { 0x0a, 0x05, 0x01, 0x00, 0x0b, 0x0b, 0x0b, 0x0b, 0x14, 0x0b, 0x0b } } ; node_ip *node = 0 ; size_t mark = hd->storage.len ; @@ -177,6 +177,12 @@ static int s6dns_hosts_parse (buffer *b, hostdata *hd) { char ip[16] ; if (!stralloc_0(&hd->storage)) goto err ; + if (state == 0x01) /* ignore link-local addresses */ + { + if (!ip6_scan(hd->storage.s + mark, ip)) goto errill ; + hd->storage.len = mark ; + continue ; + } if (ip6_scan(hd->storage.s + mark, ip)) { uint32_t d ; @@ -203,7 +209,7 @@ static int s6dns_hosts_parse (buffer *b, hostdata *hd) flags &= ~1 ; node = GENSETDYN_P(node_ip, &hd->ipv4, d) ; } - else goto err ; + else goto errill ; hd->storage.len = mark ; flags &= ~2 ; } @@ -268,6 +274,8 @@ static int s6dns_hosts_parse (buffer *b, hostdata *hd) if (state > 0x0a) return (errno = EILSEQ, 0) ; return 1 ; + errill: + errno = EILSEQ ; err: hostdata_free(hd) ; return 0 ; |