ntpd/ntpq tangle
Hal Murray
halmurray at sonic.net
Tue Jul 7 10:42:39 UTC 2026
In the process of chasing another bug, I noticed a bug in libntp/socktoa.c
In socktoa_r
} else {
switch(AF(sock)) {
case AF_INET:
inet_ntop(AF_INET, PSOCK_ADDR4(sock), buf, buflen);
break;
It had AF_UNSPEC taking the AF_INET path too. So I deleted that line.
That now takes the default path, so you get trash:
snprintf(buf, buflen,
"(socktoa unknown family %d)",
AF(sock));
I haven't pushed that fix yet.
ntpq ends up displaying DNSFAIL(xxx)
I only see it if I look before it has done the DNS lookup on names or if
the slot is pool slot. (Not the new ones, the "pool dns-name" slot that
never gets an IP Address.)
So I poked around with gdb a bit, and found what was causing the problem,
and fixed it to send nothing:
case CP_SRCADR:
+ if (AF_UNSPEC == AF(&p->srcadr))
+ break; // empty slot: pool, or no DNS yet
ctl_putadr(CV_NAME, 0, &p->srcadr);
break;
Then ntpq crashes. it can't find startswith, probably because srcadr
isn't a string.
pylib/util.py" 1456L,
elif srcadr.startswith("224."):
ptype = 'a' # manycastclient (compatibility with
Classic)
Would you please see if you can find a good/simple fix.
Thanks.
I can easily hack ntp_control to return any simple fixed text string if
that will make things simpler on your end. But maybe you should handle
the no-srcadr case anyway.
I think the old code would return "0.0.0.0"
--
These are my opinions. I hate spam.
More information about the devel
mailing list