[Git][NTPsec/ntpsec][903-stale-buffer-read-in-cvt_trimtsip-enables-controlled-clock-step-and-false-leap-second] 4 commits: libparse/clk_trimtsip.c: CHeck ;length before reading weeks.
Gary E. Miller (@garyedmundsmiller)
gitlab at mg.gitlab.com
Tue Nov 17 04:45:13 UTC 2026
Gary E. Miller pushed to branch 903-stale-buffer-read-in-cvt_trimtsip-enables-controlled-clock-step-and-false-leap-second at NTPsec / ntpsec
Commits:
d86f71d8 by Gary E. Miller at 2026-11-16T20:21:46-08:00
libparse/clk_trimtsip.c: CHeck ;length before reading weeks.
Reorder so fields read in order.
- - - - -
a4b7a068 by Gary E. Miller at 2026-11-16T20:34:40-08:00
libparse/clk_trimtsip.c: Ask for larger packet.
Reorder to read fields in buffer order.
- - - - -
3aad5931 by Gary E. Miller at 2026-11-16T20:41:40-08:00
libparse/clk_trimtsip.c: Adjust sice for CMD_RCURTIME.
- - - - -
0b840cf8 by Gary E. Miller at 2026-11-16T20:44:07-08:00
libparse/clk_trimtsip.c: Change location of size check to be obvous.
CMD_RRECVHEALTH:
- - - - -
1 changed file:
- libparse/clk_trimtsip.c
Changes:
=====================================
libparse/clk_trimtsip.c
=====================================
@@ -207,11 +207,11 @@ cvt_trimtsip(
case CMD_RCURTIME:
{ /* GPS time */
l_fp secs;
- int week = getmsb_short(&mb(4));
+ int week;
l_fp utcoffset;
l_fp gpstime;
- if (10 > size) {
+ if (13 > size) {
printf("TRIMBLE BAD packet, size %d:\n",
size);
return CVT_NONE;
@@ -227,6 +227,7 @@ cvt_trimtsip(
clock_time->flags = PARSEB_POWERUP;
return CVT_OK;
}
+ week = getmsb_short(&mb(4));
if (week < GPSWRAP) {
week += GPSWEEKS;
}
@@ -239,14 +240,15 @@ cvt_trimtsip(
trim_offsets) != IEEE_OK)
return CVT_FAIL|CVT_BADFMT;
- secs -= utcoffset; /* adjust GPS time to UTC time */
+ secs -= utcoffset; // adjust GPS time to UTC time
- gpstolfp((unsigned short)week, (unsigned short)0,
+ gpstolfp((unsigned short)week, 0,
lfpuint(secs), &gpstime);
setlfpfrac(gpstime, lfpfrac(secs));
- clock_time->utctime = (time_t)(lfpuint(gpstime) - JAN_1970);
+ clock_time->utctime = (time_t)(lfpuint(gpstime) -
+ JAN_1970);
clock_time->usecond = lfp_intv_to_tspec(gpstime).tv_nsec / 1000;
@@ -283,14 +285,16 @@ cvt_trimtsip(
case CMD_RRECVHEALTH:
{
- /* TRIMBLE health */
- uint8_t status = mb(0);
+ // TRIMBLE health
+ uint8_t status;
if (6 > size) {
printf("TRIMBLE BAD packet, size %d:\n",
size);
return CVT_NONE;
}
+
+ status = mb(0);
switch (status)
{
case 0x00: /* position fixes */
@@ -315,45 +319,49 @@ cvt_trimtsip(
{
l_fp t0t;
unsigned char *lbp;
+ int tlsf;
- if (28 > size) {
+ if (30 > size) {
printf("TRIMBLE BAD packet, size %d:\n",
size);
return CVT_NONE;
}
- /* UTC correction data - derive a leap warning */
- /* current leap correction (GPS-UTC) */
+ /* UTC correction data - derive a leap warning
+ * current leap correction (GPS-UTC) */
int tls = t->t_gpsutc = get_msb_ushort(&mb(12));
- /* new leap correction */
- int tlsf = t->t_gpsutcleap = get_msb_ushort(&mb(24));
-
- /* week no of leap correction */
- t->t_weekleap = get_msb_ushort(&mb(20));
- if (t->t_weekleap < GPSWRAP) {
- t->t_weekleap = (unsigned short)(t->t_weekleap + GPSWEEKS);
+ // last update time
+ lbp = (unsigned char *)&mb(14);
+ if (fetch_ieee754(&lbp, IEEE_SINGLE, &t0t,
+ trim_offsets) != IEEE_OK) {
+ return CVT_FAIL|CVT_BADFMT;
}
- /* day in week of leap correction */
- t->t_dayleap = get_msb_ushort(&mb(22));
- /* current week no */
+ // current week no
t->t_week = get_msb_ushort(&mb(18));
if (t->t_week < GPSWRAP) {
t->t_week += GPSWEEKS;
}
- lbp = (unsigned char *)&mb(14); /* last update time */
- if (fetch_ieee754(&lbp, IEEE_SINGLE, &t0t, trim_offsets) != IEEE_OK) {
- return CVT_FAIL|CVT_BADFMT;
+ // week no of leap correction
+ t->t_weekleap = get_msb_ushort(&mb(20));
+ if (t->t_weekleap < GPSWRAP) {
+ t->t_weekleap = t->t_weekleap + GPSWEEKS;
}
+ // day in week of leap correction
+ t->t_dayleap = get_msb_ushort(&mb(22));
+
t->t_utcknown = lfpuint(t0t) != 0;
+ // new leap correction
+ tlsf = t->t_gpsutcleap = get_msb_ushort(&mb(24));
- if ((t->t_utcknown) && /* got UTC information */
- (tlsf != tls) && /* something will change */
- ((t->t_weekleap - t->t_week) < 5)) /* and close in the future */
+ if ((t->t_utcknown) && // got UTC information
+ (tlsf != tls) && // something will change
+ // and close in the future
+ ((t->t_weekleap - t->t_week) < 5))
{
- /* generate a leap warning */
+ // generate a leap warning
if (tlsf > tls) {
t->t_leap = ADDSECOND;
} else {
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/-/compare/0642ecf9be90d696eecadb68b53570a06958a9c3...0b840cf8d7ee912f390ea1e99077654b1bb644e8
--
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/-/compare/0642ecf9be90d696eecadb68b53570a06958a9c3...0b840cf8d7ee912f390ea1e99077654b1bb644e8
You're receiving this email because of your account on gitlab.com. Manage all notifications: https://gitlab.com/-/profile/notifications | Help: https://gitlab.com/help
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20261117/461b9176/attachment-0001.htm>
More information about the vc
mailing list