summaryrefslogtreecommitdiffstats
path: root/contrib/ntp/ntpd/refclock_gpsdjson.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/ntp/ntpd/refclock_gpsdjson.c')
-rw-r--r--contrib/ntp/ntpd/refclock_gpsdjson.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/contrib/ntp/ntpd/refclock_gpsdjson.c b/contrib/ntp/ntpd/refclock_gpsdjson.c
index 7c49311..00cd3fc 100644
--- a/contrib/ntp/ntpd/refclock_gpsdjson.c
+++ b/contrib/ntp/ntpd/refclock_gpsdjson.c
@@ -2112,13 +2112,15 @@ save_ltc(
clockprocT * const pp,
const char * const tc)
{
- size_t len;
-
- len = (tc) ? strlen(tc) : 0;
- if (len >= sizeof(pp->a_lastcode))
- len = sizeof(pp->a_lastcode) - 1;
+ size_t len = 0;
+
+ if (tc) {
+ len = strlen(tc);
+ if (len >= sizeof(pp->a_lastcode))
+ len = sizeof(pp->a_lastcode) - 1;
+ memcpy(pp->a_lastcode, tc, len);
+ }
pp->lencode = (u_short)len;
- memcpy(pp->a_lastcode, tc, len);
pp->a_lastcode[len] = '\0';
}
OpenPOWER on IntegriCloud