File kdumpid-x86_64-fix-NULL-arch-segv.patch of Package kdumpid
Date: Mon Nov 3 21:48:25 CET 2014
From: Petr Tesarik <ptesarik@suse.cz>
Subject: Fix SEGV when checking x86_64 and arch is unknown
Patch-mainline: not yet
The probe for x86_64 avoids checking the architecture if it is known already.
However, this check uses strcmp(), which does not work with NULL pointers,
but a NULL pointer is used to specify unknown architecture.
Signed-off-by: Petr Tesarik <ptesarik@suse.cz>
---
x86.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
--- a/x86.c
+++ b/x86.c
@@ -258,7 +258,8 @@ looks_like_kcode_x86(struct dump_desc *d
/* Try i386 code first */
info.mach = bfd_mach_i386_i386;
disassemble_init_for_target(&info);
- if (strcmp(dd->arch, "x86_64") && disas_at(dd, &info, 0) > 0) {
+ if ((!dd->arch || strcmp(dd->arch, "x86_64")) &&
+ disas_at(dd, &info, 0) > 0) {
free(priv);
return 1;
}
@@ -267,7 +268,8 @@ looks_like_kcode_x86(struct dump_desc *d
memset(priv, 0, sizeof(struct disas_priv) + dd->page_size / 8);
info.mach = bfd_mach_x86_64;
disassemble_init_for_target(&info);
- if (strcmp(dd->arch, "i386") && disas_at(dd, &info, 0) > 0) {
+ if ((!dd->arch || strcmp(dd->arch, "i386")) &&
+ disas_at(dd, &info, 0) > 0) {
free(priv);
return 1;
}