svn commit: r351461 - head/sbin/ping
Alan Somers
asomers at FreeBSD.org
Sat Aug 24 18:00:19 UTC 2019
Author: asomers
Date: Sat Aug 24 18:00:18 2019
New Revision: 351461
URL: https://svnweb.freebsd.org/changeset/base/351461
Log:
ping: fix unaligned access to ancillary data
Use CMSG_FIRSTHDR rather than assume that an array is correctly aligned.
Fixes warnings on sparc64 and powerpcspe.
Submitted by: Ján Sučan <sucanjan at gmail.com>
MFH: 2 weeks
Sponsored by: Google LLC (Google Summer of Code 2019)
Differential Revision: https://reviews.freebsd.org/D21406
Modified:
head/sbin/ping/ping.c
Modified: head/sbin/ping/ping.c
==============================================================================
--- head/sbin/ping/ping.c Sat Aug 24 16:44:47 2019 (r351460)
+++ head/sbin/ping/ping.c Sat Aug 24 18:00:18 2019 (r351461)
@@ -875,6 +875,7 @@ main(int argc, char *const *argv)
msg.msg_iovlen = 1;
#ifdef SO_TIMESTAMP
msg.msg_control = (caddr_t)ctrl;
+ msg.msg_controllen = sizeof(ctrl);
#endif
iov.iov_base = packet;
iov.iov_len = IP_MAXPACKET;
@@ -920,9 +921,7 @@ main(int argc, char *const *argv)
if (n == 1) {
struct timespec *tv = NULL;
#ifdef SO_TIMESTAMP
- struct cmsghdr *cmsg = (struct cmsghdr *)&ctrl;
-
- msg.msg_controllen = sizeof(ctrl);
+ struct cmsghdr *cmsg = CMSG_FIRSTHDR(&msg);
#endif
msg.msg_namelen = sizeof(from);
if ((cc = recvmsg(srecv, &msg, 0)) < 0) {
More information about the svn-src-head
mailing list