[Git][NTPsec/ntpsec][master] Add a pedantic overrun check that should never actually fire.

Eric S. Raymond gitlab at mg.gitlab.com
Sat Feb 11 13:31:14 UTC 2017


Eric S. Raymond pushed to branch master at NTPsec / ntpsec


Commits:
a97861b4 by Eric S. Raymond at 2017-02-11T08:31:03-05:00
Add a pedantic overrun check that should never actually fire.

- - - - -


1 changed file:

- ntpd/refclock_magnavox.c


Changes:

=====================================
ntpd/refclock_magnavox.c
=====================================
--- a/ntpd/refclock_magnavox.c
+++ b/ntpd/refclock_magnavox.c
@@ -1578,7 +1578,9 @@ mx4200_send(struct peer *peer, char *fmt, ...)
 	ck = mx4200_cksum(cp, n);
 	cp += n;
 	++n;
-	n += snprintf(cp, sizeof(buf) - n - 5, "*%02X\r\n", ck);
+	/* should always fire, it's only here to make overrun impossible */ 
+	if (sizeof(buf) - n >= 5)
+	    n += snprintf(cp, sizeof(buf) - n - 5, "*%02X\r\n", ck);
 
 	m = write(pp->io.fd, buf, (unsigned)n);
 	if (m < 0)



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/a97861b41d00349386f506d9d3ab3682aa6d98a8
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20170211/dd190950/attachment.html>


More information about the vc mailing list