]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
[Bug 2808] - GPSD_JSON driver enhancements, step 1
authorJuergen Perlinger <perlinger@ntp.org>
Wed, 29 Apr 2015 16:58:30 +0000 (18:58 +0200)
committerJuergen Perlinger <perlinger@ntp.org>
Wed, 29 Apr 2015 16:58:30 +0000 (18:58 +0200)
  fix coverity issues in refclock_shm and refclock_gpsdjson

bk: 55410db6I_9BXnVoZWcTmmKoJGJuPg

ChangeLog
libjsmn/jsmn.c
ntpd/refclock_gpsdjson.c
ntpd/refclock_shm.c

index 63a13b38fa53912c9d8a86eecbf4ecedcf734b48..6ddd568034f1afdd3b78947058b757fa22a1827b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
 ---
 
+* [Bug 2808] GPSD_JSON driver enhancements, step 1
+  fix coverity issues with refclock_gpsdjson and refclock_shm
 * [Bug 2808] GPSD_JSON driver enhancements, step 1.
   Add a few more tallies as per Hal Murray's suggestions
 * [Bug 2794] Clean up kernel clock status reports.
index a0f4f69c6710939fefb2c4d04cbfa5b0e5a19946..2e88fe140d49600eee4561e92818ab05b49848d6 100644 (file)
@@ -288,11 +288,12 @@ jsmnerr_t jsmn_parse(jsmn_parser *parser, const char *js, size_t len,
 #endif
                }
        }
-
-       for (i = parser->toknext - 1; i >= 0; i--) {
-               /* Unmatched opened object or array */
-               if (tokens[i].start != -1 && tokens[i].end == -1) {
-                       return JSMN_ERROR_PART;
+       if (tokens != NULL) {
+               for (i = parser->toknext - 1; i >= 0; i--) {
+                       /* Unmatched opened object or array */
+                       if (tokens[i].start != -1 && tokens[i].end == -1) {
+                               return JSMN_ERROR_PART;
+                       }
                }
        }
 
index 89445223a0c2ad77beb33ddba82a60417197b364..464cdfb7a3ee33d15fddf35da8ff83446a7def14 100644 (file)
@@ -894,7 +894,6 @@ eval_strict(
                /* use TPV reference time + PPS receive time */
                add_clock_sample(peer, pp, up->sti_stamp, up->pps_recvt);
                peer->precision = up->pps_prec;
-               //DEAD? up->tc_good += 1;
                /* both packets consumed now... */
                up->fl_pps = 0;
                up->fl_sti = 0;
@@ -940,7 +939,6 @@ eval_serial(
        if (up->fl_sti) {
                add_clock_sample(peer, pp, up->sti_stamp, up->sti_recvt);
                peer->precision = up->sti_prec;
-               //DEAD? up->tc_good += 1;
                /* mark time stamp as burned... */
                up->fl_sti = 0;
                ++up->tc_sti_used;
@@ -1126,6 +1124,9 @@ json_object_lookup(
                } else {
                        break;
                }
+               /* if skipping ahead returned an error, bail out here. */
+               if (tid < 0)
+                       break;
        }
        return INVALID_TOKEN;
 }
index 7174abdbf4cf3a4765a9b108732dd476ef7a2dd5..7f644dfc7452053d7950943a4defb191aa7d633b 100644 (file)
@@ -144,7 +144,6 @@ getShmTime(
                msyslog(LOG_ERR, "SHM shmat (unit %d): %m", unit);
                return NULL;
        }
-       return p;
 
 #else