svn commit: r321228 - head/usr.sbin/crashinfo

Mark Johnston markj at FreeBSD.org
Wed Jul 19 18:41:17 UTC 2017


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


More information about the svn-src-all mailing list