Currently, get_pt_note_info() checks ELF note in "VMCOREINFO_XEN" name first and then in "VMCOREINFO" name to avoid the case where "VMCOREINFO_XEN" is wrongly interpreted as "VMCOREINFO". However, characters checked by strncmp() includes null character. The case concerned about there can never happen. This patch swaps checking order of VMCOREINFO and VMCOREINFO_XEN, which is natural in the sense that the direction from general one to specific one is natural. Signed-off-by: HATAYAMA Daisuke <d.hatayama at jp.fujitsu.com> --- elf_info.c | 13 ++++--------- 1 files changed, 4 insertions(+), 9 deletions(-) diff --git a/elf_info.c b/elf_info.c index b0e45b5..f9c554d 100644 --- a/elf_info.c +++ b/elf_info.c @@ -323,22 +323,17 @@ get_pt_note_info(void) offset_desc = offset + offset_note_desc(note); size_desc = note_descsz(note); + if (!strncmp(VMCOREINFO_NOTE_NAME, buf, + VMCOREINFO_NOTE_NAME_BYTES)) { + set_vmcoreinfo(offset_desc, size_desc); /* * Check whether /proc/vmcore contains vmcoreinfo, * and get both the offset and the size. - * - * NOTE: The owner name of xen should be checked at first, - * because its name is "VMCOREINFO_XEN" and the one - * of linux is "VMCOREINFO". */ - if (!strncmp(VMCOREINFO_XEN_NOTE_NAME, buf, + } else if (!strncmp(VMCOREINFO_XEN_NOTE_NAME, buf, VMCOREINFO_XEN_NOTE_NAME_BYTES)) { offset_vmcoreinfo_xen = offset_desc; size_vmcoreinfo_xen = size_desc; - } else if (!strncmp(VMCOREINFO_NOTE_NAME, buf, - VMCOREINFO_NOTE_NAME_BYTES)) { - set_vmcoreinfo(offset_desc, size_desc); - /* * Check whether /proc/vmcore contains xen's note. */