Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 11 Sep 2019 18:54:45 +0000 (UTC)
From:      Alan Somers <asomers@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r352229 - head/sbin/ping
Message-ID:  <201909111854.x8BIsjKc062005@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: asomers
Date: Wed Sep 11 18:54:45 2019
New Revision: 352229
URL: https://svnweb.freebsd.org/changeset/base/352229

Log:
  ping: Verify whether a datagram timestamp was actually received.
  
  ping(8) uses SO_TIMESTAMP, which attaches a timestamp to each IP datagram at
  the time it's received by the kernel.  Except that occasionally it doesn't.
  Add a check to see whether such a timestamp was actually set before trying
  to read it.  This fixes segfaults that can happen when the kernel doesn't
  attach a timestamp.
  
  The bug has always existed, but prior to r351461 it manifested as an
  implausible round-trip-time, not a segfault.
  
  Reported by:	pho
  MFC after:	3 days
  MFC-With:	351461

Modified:
  head/sbin/ping/ping.c

Modified: head/sbin/ping/ping.c
==============================================================================
--- head/sbin/ping/ping.c	Wed Sep 11 18:48:26 2019	(r352228)
+++ head/sbin/ping/ping.c	Wed Sep 11 18:54:45 2019	(r352229)
@@ -931,7 +931,8 @@ main(int argc, char *const *argv)
 				continue;
 			}
 #ifdef SO_TIMESTAMP
-			if (cmsg->cmsg_level == SOL_SOCKET &&
+			if (cmsg != NULL &&
+			    cmsg->cmsg_level == SOL_SOCKET &&
 			    cmsg->cmsg_type == SCM_TIMESTAMP &&
 			    cmsg->cmsg_len == CMSG_LEN(sizeof *tv)) {
 				/* Copy to avoid alignment problems: */



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201909111854.x8BIsjKc062005>