]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
CID 709185: refclock_chu.c will leak fd==0 (better fix)
authorHarlan Stenn <stenn@ntp.org>
Tue, 17 Jul 2012 05:15:11 +0000 (01:15 -0400)
committerHarlan Stenn <stenn@ntp.org>
Tue, 17 Jul 2012 05:15:11 +0000 (01:15 -0400)
bk: 5004f4dfo1TAB3JE-LAyloVgtiiftw

ChangeLog
ntpd/refclock_chu.c

index 224a23c1cff3346e0330f67e2b9385c958e0f0c2..8c32fdebdf2e7c286d4967ee9c1d8882e7fbacc8 100644 (file)
--- 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 <stenn@ntp.org>
 * CID 97123: Future-proof possible change to refclock_nmea.c.
 * CID 97377: ntp-keygen.c's followlink() might not NUL-terminate.
index 48b67536fb9410a8daa832cc17a113d9389ed730..9c7093d2c2129ed4815ba1df89bdb0f10fb3c533 100644 (file)
@@ -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);
 
        /*