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
This commit is contained in:
Mark Johnston 2017-07-19 18:41:16 +00:00
parent 274b460b60
commit 5a3924b985

View File

@ -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