[Git][NTPsec/ntpsec][master] A fix for the packet-dumping code.

Eric S. Raymond gitlab at mg.gitlab.com
Tue Dec 15 15:49:35 UTC 2015


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


Commits:
ed15ddc7 by Eric S. Raymond at 2015-12-15T10:48:58Z
A fix for the packet-dumping code.

This case hadn't been exercised yet.  Itcould fire only on a packet
with a MAC.

- - - - -


1 changed file:

- ntpd/ntp_intercept.c


Changes:

=====================================
ntpd/ntp_intercept.c
=====================================
--- a/ntpd/ntp_intercept.c
+++ b/ntpd/ntp_intercept.c
@@ -644,8 +644,12 @@ static void packet_dump(char *buf, size_t buflen,
 	   lfpdump(&pkt->reftime), lfpdump(&pkt->org),
 	   lfpdump(&pkt->rec), lfpdump(&pkt->xmt));
     /* dump MAC as len - LEN_PKT_NOMAC chars in hex */
-    for (i = 0; i < len - LEN_PKT_NOMAC; i++)
-	printf("%02x", pkt->exten[i]);
+    for (i = 0; i < len - LEN_PKT_NOMAC; i++) {
+	if (i == 0)
+	    strlcat(buf, " ", buflen);
+	snprintf(buf + strlen(buf), buflen - strlen(buf),
+		 "%02x", pkt->exten[i]);
+    }
 }
 
 void intercept_sendpkt(const char *legend,



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


More information about the vc mailing list