Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/dist/ntp/ntpd PR/27137: Martin J. Laubach: core dump when lo...



details:   https://anonhg.NetBSD.org/src/rev/337addcd30e0
branches:  trunk
changeset: 570342:337addcd30e0
user:      christos <christos%NetBSD.org@localhost>
date:      Tue Oct 05 03:34:38 2004 +0000

description:
PR/27137: Martin J. Laubach: core dump when localhost does not support
a given address family and a peer only supports the family localhost does
not support. For example: configure a kernel without IPV6, and then
add a line in ntp.conf server <ipv6addr>. We report that the server is
unreachable and we keep going because there might be more servers around?
XXX: What if it is the last server? Should we detect this? It is not nice
to just bail on this error, because a server might lose its ipv4 address
and only advertise ipv6.

diffstat:

 dist/ntp/ntpd/ntp_io.c    |  11 ++++++++---
 dist/ntp/ntpd/ntp_proto.c |   5 +++--
 2 files changed, 11 insertions(+), 5 deletions(-)

diffs (52 lines):

diff -r 3a47c284f09d -r 337addcd30e0 dist/ntp/ntpd/ntp_io.c
--- a/dist/ntp/ntpd/ntp_io.c    Tue Oct 05 03:03:24 2004 +0000
+++ b/dist/ntp/ntpd/ntp_io.c    Tue Oct 05 03:34:38 2004 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ntp_io.c,v 1.10 2003/12/20 17:38:19 fredb Exp $        */
+/*     $NetBSD: ntp_io.c,v 1.11 2004/10/05 03:34:38 christos Exp $     */
 
 /*
  * ntp_io.c - input/output routines for ntpd.  The socket-opening code
@@ -1381,9 +1381,13 @@
        if (debug > 1)
            printf("%ssendpkt(fd=%d dst=%s, src=%s, ttl=%d, len=%d)\n",
                   (ttl >= 0) ? "\tMCAST\t*****" : "",
-                  inter->fd, stoa(dest),
-                  stoa(&inter->sin), ttl, len);
+                  inter ? inter->fd : -1, stoa(dest),
+                  inter ? stoa(&inter->sin) : "null", ttl, len);
 #endif
+       if (inter == NULL) {
+               errno = EAFNOSUPPORT;
+               goto nointerface;
+       }
 
 #ifdef MCAST
 
@@ -1468,6 +1472,7 @@
 #endif
        {
                inter->notsent++;
+nointerface:
                packets_notsent++;
 #if defined(HAVE_IO_COMPLETION_PORT)
                err = WSAGetLastError();
diff -r 3a47c284f09d -r 337addcd30e0 dist/ntp/ntpd/ntp_proto.c
--- a/dist/ntp/ntpd/ntp_proto.c Tue Oct 05 03:03:24 2004 +0000
+++ b/dist/ntp/ntpd/ntp_proto.c Tue Oct 05 03:34:38 2004 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ntp_proto.c,v 1.3 2003/12/04 17:22:31 drochner Exp $   */
+/*     $NetBSD: ntp_proto.c,v 1.4 2004/10/05 03:34:38 christos Exp $   */
 
 /*
  * ntp_proto.c - NTP version 4 protocol machinery
@@ -2368,7 +2368,8 @@
 #ifdef DEBUG
                if (debug)
                        printf("transmit: at %ld %s->%s mode %d\n",
-                           current_time, stoa(&peer->dstadr->sin),
+                           current_time, peer->dstadr ?
+                           stoa(&peer->dstadr->sin) : "null",
                            stoa(&peer->srcadr), peer->hmode);
 #endif
                return;



Home | Main Index | Thread Index | Old Index