[Crash-utility] A patch for match_file_string()

Dave Anderson anderson at redhat.com
Fri Mar 14 13:35:59 UTC 2008


Alex Sidorenko wrote:
> On March 13, 2008 05:23:58 pm Dave Anderson wrote:
> 
> Hi Dave,
> 
> even though my fix works, explanation was incorrect :-(
> 
> Yes, both strings are LF-terminated, but on Ubuntu the string in 'strings' 
> output has extra information appended at the end.
> 
> /proc/version:
> 
> Linux version 2.6.22-14-generic (buildd at terranova) (gcc version 4.1.3 20070929 
> (prerelease) (Ubuntu 4.1.2-16ubuntu2)) #1 SMP Tue Feb 12 07:42:25 UTC 2008
> 
> 'strings' output:
> Linux version 2.6.22-14-generic (buildd at terranova) (gcc version 4.1.3 20070929 
> (prerelease) (Ubuntu 4.1.2-16ubuntu2)) #1 SMP Tue Feb 12 07:42:25 UTC 2008 
> (Ubuntu 2.6.22-14.52-generic)
> 
> So on Ubuntu there is additional '(Ubuntu 2.6.22-14.52-generic)' after the 
> string itself.
> 
> This is more of the problem we discussed and fixed in
> 
> http://www.mail-archive.com/crash-utility%40redhat.com/msg00442.html
> 
> Now  match_file_string() is used in two places to compare with 
> kt->proc_version and in one place with
> 
> if (!match_file_string(system_map, "D system_utsname", buffer))
> 
> Stripping LF makes strstr() find a partial match. This should be OK for 
> comparisons with /proc/version and I think it's OK for "D system_utsname" 
> either. 
> 
> Regards,
> Alex

After refreshing my memory banks, I remembered the earlier Ubuntu
inspired patch -- thanks for pulling out the post.

Anyway, since match_file_string() is used by multiple entities, and in
the future a caller may actually want to include the linefeed, it doesn't
seem appropriate to make the change there.

Can you test the attached patch on both a live system and a dumpfile?
It strips the linefeed from the version string when it's initialized,
and makes a couple other minor adjustments, including to the first Ubuntu
patch, which shouldn't be required any more.

Thanks,
   Dave


-------------- next part --------------
A non-text attachment was scrubbed...
Name: version.patch
Type: text/x-patch
Size: 1541 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/crash-utility/attachments/20080314/ee7262e2/attachment.bin>


More information about the Crash-utility mailing list