From: Harlan Stenn Date: Tue, 17 Jul 2012 05:15:11 +0000 (-0400) Subject: CID 709185: refclock_chu.c will leak fd==0 (better fix) X-Git-Tag: NTP_4_2_7P290~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=96898d4055c05f0136b04388b287f5070b9d4bda;p=thirdparty%2Fntp.git CID 709185: refclock_chu.c will leak fd==0 (better fix) bk: 5004f4dfo1TAB3JE-LAyloVgtiiftw --- diff --git a/ChangeLog b/ChangeLog index 224a23c1c..8c32fdebd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,4 @@ +* CID 709185: refclock_chu.c will leak fd==0 (better fix) (4.2.7p289) 2012/07/16 Released by Harlan Stenn * CID 97123: Future-proof possible change to refclock_nmea.c. * CID 97377: ntp-keygen.c's followlink() might not NUL-terminate. diff --git a/ntpd/refclock_chu.c b/ntpd/refclock_chu.c index 48b67536f..9c7093d2c 100644 --- a/ntpd/refclock_chu.c +++ b/ntpd/refclock_chu.c @@ -481,25 +481,15 @@ chu_start( */ fd_audio = audio_init(DEVICE_AUDIO, AUDIO_BUFSIZ, unit); - /* - ** refclock_irig.c and refclock_wwv.c call audio_init() too, - ** but they tolerate fd == 0. - ** - ** This code will leak a file descriptor if it is 0. - ** - ** For now... - */ - INSIST(0 != fd_audio); /* Coverity 709185 */ - #ifdef DEBUG - if (fd_audio > 0 && debug) + if (fd_audio >= 0 && debug) audio_show(); #endif /* * If audio is unavailable, Open serial port in raw mode. */ - if (fd_audio > 0) { + if (fd_audio >= 0) { fd = fd_audio; } else { snprintf(device, sizeof(device), DEVICE, unit); @@ -513,7 +503,8 @@ chu_start( snprintf(device, sizeof(device), DEVICE, unit); fd = refclock_open(device, SPEED232, LDISC_RAW); #endif /* HAVE_AUDIO */ - if (fd <= 0) + + if (fd < 0) return (0); /*