Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 19 Jul 2017 18:41:16 +0000 (UTC)
From:      Mark Johnston <markj@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r321228 - head/usr.sbin/crashinfo
Message-ID:  <201707191841.v6JIfGq6078141@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: markj
Date: Wed Jul 19 18:41:16 2017
New Revision: 321228
URL: https://svnweb.freebsd.org/changeset/base/321228

Log:
  Allow matches of truncated version strings.
  
  Long objdir paths make it easy to hit the version string length limit in
  kernel dump headers. The build number and timestamp are unlikely to be
  truncated and ought to be sufficient to protect against false positives.
  
  Discussed with:	jhb
  MFC after:	1 week

Modified:
  head/usr.sbin/crashinfo/crashinfo.sh

Modified: head/usr.sbin/crashinfo/crashinfo.sh
==============================================================================
--- head/usr.sbin/crashinfo/crashinfo.sh	Wed Jul 19 18:30:16 2017	(r321227)
+++ head/usr.sbin/crashinfo/crashinfo.sh	Wed Jul 19 18:41:16 2017	(r321228)
@@ -83,10 +83,12 @@ find_kernel()
 		}
 	}' $INFO)
 
-	# Look for a matching kernel version.
+	# Look for a matching kernel version, handling possible truncation
+	# of the version string recovered from the dump.
 	for k in `sysctl -n kern.bootfile` $(ls -t /boot/*/kernel); do
-		kvers=$(gdb_command $k 'printf "  Version String: %s", version' \
-		     2>/dev/null)
+		kvers=$(gdb_command $k 'printf "  Version String: %s", version' | \
+		    awk "{line=line\$0\"\n\"} END{print substr(line,1,${#ivers})}" \
+		    2>/dev/null)
 		if [ "$ivers" = "$kvers" ]; then
 			KERNEL=$k
 			break



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