From: Harlan Stenn Date: Tue, 12 Oct 2010 05:06:48 +0000 (-0400) Subject: [Bug 750]: Non-existing device causes coredump with RIPE-NCC driver X-Git-Tag: NTP_4_2_7P62~2^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0493c5bcc71a0ab6934a681b2ba25e9d5a963b2c;p=thirdparty%2Fntp.git [Bug 750]: Non-existing device causes coredump with RIPE-NCC driver bk: 4cb3ece8Nab88ycCS5IEuo2nN0nhtA --- diff --git a/ChangeLog b/ChangeLog index 64ef08d1e..fb24902a6 100644 --- 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. diff --git a/ntpd/refclock_ripencc.c b/ntpd/refclock_ripencc.c index 871fe8113..02a1dc4dc 100644 --- a/ntpd/refclock_ripencc.c +++ b/ntpd/refclock_ripencc.c @@ -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,