[Git][NTPsec/ntpsec][issue890] ntpd/refclock_zyfer.c: ensure a_lastcode us NUL terminated.

Gary E. Miller (@garyedmundsmiller) gitlab at mg.gitlab.com
Thu Jul 30 03:42:14 UTC 2026



Gary E. Miller pushed to branch issue890 at NTPsec / ntpsec


Commits:
f82c5712 by Gary E. Miller at 2026-07-29T20:41:12-07:00
ntpd/refclock_zyfer.c: ensure a_lastcode us NUL terminated.

Add more safetye checks, suggested by Grok.

- - - - -


1 changed file:

- ntpd/refclock_zyfer.c


Changes:

=====================================
ntpd/refclock_zyfer.c
=====================================
@@ -210,12 +210,21 @@ zyfer_receive(
 		else
 			return;
 	} else {
+                if (pp->lencode < 0 ||
+                    (size_t)pp->lencode >= sizeof(pp->a_lastcode) - 1) {
+                    pp->lencode = 0;
+                    pp->a_lastcode[0] = '\0';
+                    refclock_report(peer, CEVNT_BADREPLY);
+                    return;
+                }
+
                 size_t avail = sizeof(pp->a_lastcode) - (1 + pp->lencode);
-		if (rbufp->recv_length >= avail) {
-			pp->lencode = 0;
-			refclock_report(peer, CEVNT_BADREPLY);
-			return;
-		}
+                if (rbufp->recv_length >= avail) {
+                        pp->lencode = 0;
+                        pp->a_lastcode[0] = '\0';
+                        refclock_report(peer, CEVNT_BADREPLY);
+                        return;
+                }
 
 		memcpy(pp->a_lastcode + pp->lencode, p, rbufp->recv_length);
 		pp->lencode += (int)rbufp->recv_length;



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/-/commit/f82c5712a0b541523e47f796bb5aa5a29f51699e

-- 
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/-/commit/f82c5712a0b541523e47f796bb5aa5a29f51699e
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/20260730/310eeb0e/attachment-0001.htm>


More information about the vc mailing list