]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
[Bug 750]: Non-existing device causes coredump with RIPE-NCC driver
authorHarlan Stenn <stenn@ntp.org>
Tue, 12 Oct 2010 05:06:48 +0000 (01:06 -0400)
committerHarlan Stenn <stenn@ntp.org>
Tue, 12 Oct 2010 05:06:48 +0000 (01:06 -0400)
bk: 4cb3ece8Nab88ycCS5IEuo2nN0nhtA

ChangeLog
ntpd/refclock_ripencc.c

index 64ef08d1e3a576064f1000a6aecfcb7b7f7da11a..fb24902a617eed3d55c3a33c90f5f87af5ff60ba 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,9 +1,10 @@
 ---
 
-* [Bug 1567] Support Arbiter 1093C Satellite Clock on Windows.
+* [Bug 750]: Non-existing device causes coredump with RIPE-NCC driver.
+* [Bug 1567]: Support Arbiter 1093C Satellite Clock on Windows.
 * [Bug 1643]: Range-check the decoding of the RIPE-NCC status codes.
 * [Bug 1644]: cvo.sh should use lsb_release to identify linux distros.
-* [Bug 1659] Support Truetime Satellite Clocks on Windows.
+* [Bug 1659]: Support Truetime Satellite Clocks on Windows.
 * [Bug 1660]: On some systems, test is in /usr/bin, not /bin.
 * [Bug 1661]: Re-indent refclock_ripencc.c.
 
index 871fe81134cc4ab140439b1e97da72b9c590c1ce..02a1dc4dc4a2269f8a8cf969b5ddd8aaa8e6fa33 100644 (file)
@@ -471,12 +471,18 @@ ripencc_start(int unit, struct peer *peer)
        struct termios tio;
        TSIPPKT spt;
 
+       pp = peer->procptr;
+
        /*
         * Open serial port
         */
        (void)snprintf(device, sizeof(device), DEVICE, unit);
-       if (!(fd = refclock_open(device, SPEED232, LDISC_RAW)))
+       if (!(fd = refclock_open(device, SPEED232, LDISC_RAW))) {
+               pp->io.fd = -1;
                return (0);
+       }
+
+       pp->io.fd = fd;
 
        /* from refclock_palisade.c */
        if (tcgetattr(fd, &tio) < 0) {
@@ -503,12 +509,12 @@ ripencc_start(int unit, struct peer *peer)
                return (0);
        }
        memset((char *)up, 0, sizeof(struct ripencc_unit));
-       pp = peer->procptr;
+
        pp->io.clock_recv = ripencc_receive;
        pp->io.srcclock = (caddr_t)peer;
        pp->io.datalen = 0;
-       pp->io.fd = fd;
        if (!io_addclock(&pp->io)) {
+               /* XXX HMS: Do we need to set pp->io.fd to -1 here? */
                (void) close(fd);
                free(up);
                return (0);
@@ -770,12 +776,15 @@ ripencc_shutdown(int unit, struct peer *peer)
        pp = peer->procptr;
        up = (struct ripencc_unit *)pp->unitptr;
 
-       if (up->handle != 0)
-               time_pps_destroy(up->handle);
-
-       io_closeclock(&pp->io);
+       if (up != NULL) {
+               if (up->handle != 0)
+                       time_pps_destroy(up->handle);
+               free(up);
+       }
+       if (-1 != pp->io.fd)
+               io_closeclock(&pp->io);
 
-       free(up);
+       return;
 }
 
 /*
@@ -1097,7 +1106,7 @@ cmd_0x2F(
 
 /* set serial I/O options */
 void
-md_0x35s(
+cmd_0x35s(
         TSIPPKT *cmd,
         unsigned char pos_code,
         unsigned char vel_code,