Re: [chrony-dev] nameserv.c unused #ifdef and getnameinfo result ignored

[ Thread Index | Date Index | More chrony.tuxfamily.org/chrony-dev Archives ]


Bill Unruh wrote:
> In the file nameserver.c in the function DNS_IPAddress2Name
> the program starts out with an
>  #ifdef HAVE_IPV6 ....
> #else
> ...
> #ifdef HAVE_IPV6
> ...
> #endif
> ...
> #endif
> 
> That second block of #ifdef HAVE_IPV6 will never be used since it is in a
> block that is run only if HAVE_IPV6 is not set.

That's ok, there are two code paths, one for getnameinfo and one for
gethostbyaddr. Both support IPv6, but the first one is currently
preferred if IPv6 support is enabled.

> Also, this routine simply accepts anything that the getnameinfo throws at it
> without doing any error checking.

It checks for the return code. If there is an error, IPToString is
called to provide the output.

> In client.c:
> 
> Hmm, the hostname_buff in  process_smd_clients and process_cmd_sources is only 32 bytes long, which is arguably too small for an ipv6
> address, of which only 25 bytes are displayed-- is this enough to display a
> unique ipv6 address to a source?
> In process_cmd_tracking the buffer "host" is 50 bytes long instead which seems
> more reasonable.

Good point, this should be fixed.

> Note that in process_cmd_tracking, the report seems to be aimed at IPV4, and
> would fall apart with IPV6.
> 
> eg:
> printf("Reference ID    : %lu.%lu.%lu.%lu (%s)\n", a, b, c, d, ref_ip);

The reference ID is always 32 bits (for IPv6 address it's its MD5 sum)
and the IP address or refid as string for refclocks is printed in
parentheses. But I agree it may be confusing, suggestions welcomed.

> Looking over the code again, there seems to be a problem in client.c function
> parse_allow_deny with the function assuming that the address is an IPV4
> address. See for example
> if (!UTI_StringToIP(p, &ip) &&
>         (n = sscanf(p, "%lu.%lu.%lu.%lu", &a, &b, &c, &d)) == 0) {
> which seems to assume that the address read in is IPV4.

That should be ok. The sscanf is called only when UTI_StringToIP fails
which will be only for incomplete IPv4 addresses like a.b.c or a.b.
For IPv6 addresses only the ::/bits notation may be used.

> Ie, there seems to be something wrong in NetBSD with the getnameinfo function.
> (That error message is pretty uninformative.)

After a bit of googling it looks like NetBSD requires sin_len and
sin6_len fiels to be set, I'll look into it later.

-- 
Miroslav Lichvar

---
To unsubscribe email chrony-dev-request@xxxxxxxxxxxxxxxxxxxx with "unsubscribe" in the subject.
For help email chrony-dev-request@xxxxxxxxxxxxxxxxxxxx with "help" in the subject.
Trouble?  Email listmaster@xxxxxxxxxxxxxxxxxxxx.


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/