From: Juergen Perlinger Date: Wed, 29 Apr 2015 16:58:30 +0000 (+0200) Subject: [Bug 2808] - GPSD_JSON driver enhancements, step 1 X-Git-Tag: NTP_4_3_24~2^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0ce4d29c6b2ccbda365cb9290ec367e31f1e5ebc;p=thirdparty%2Fntp.git [Bug 2808] - GPSD_JSON driver enhancements, step 1 fix coverity issues in refclock_shm and refclock_gpsdjson bk: 55410db6I_9BXnVoZWcTmmKoJGJuPg --- diff --git a/ChangeLog b/ChangeLog index 63a13b38f..6ddd56803 100644 --- 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. diff --git a/libjsmn/jsmn.c b/libjsmn/jsmn.c index a0f4f69c6..2e88fe140 100644 --- a/libjsmn/jsmn.c +++ b/libjsmn/jsmn.c @@ -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; + } } } diff --git a/ntpd/refclock_gpsdjson.c b/ntpd/refclock_gpsdjson.c index 89445223a..464cdfb7a 100644 --- a/ntpd/refclock_gpsdjson.c +++ b/ntpd/refclock_gpsdjson.c @@ -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; } diff --git a/ntpd/refclock_shm.c b/ntpd/refclock_shm.c index 7174abdbf..7f644dfc7 100644 --- a/ntpd/refclock_shm.c +++ b/ntpd/refclock_shm.c @@ -144,7 +144,6 @@ getShmTime( msyslog(LOG_ERR, "SHM shmat (unit %d): %m", unit); return NULL; } - return p; #else