[PATCH] Fix segmentation fault when read_string() fails

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



When read_string() fails, error() dereferences the name variable to print the
nullchar that the variable points to. However, name points to a nullchar that
is not in crash's memory-space thus triggering a segmentation fault. This
commit replaces %s in the error message with %p so the address is printed
instead.

Signed-off-by: Matias Ezequiel Vara Larsen <matias.vara@xxxxxxxx>
---
 memory.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/memory.c b/memory.c
index c80ef61..8a1c055 100644
--- a/memory.c
+++ b/memory.c
@@ -6599,7 +6599,7 @@ page_flags_init_from_pageflag_names(void)
 		}
 
 		if (!read_string((ulong)name, namebuf, BUFSIZE-1)) {
-			error(INFO, "failed to read pageflag_names entry (i: %d  name: \"%s\"  mask: %ld)\n",
+			error(INFO, "failed to read pageflag_names entry (i: %d  name: \"%p\"  mask: %ld)\n",
 				i, name, mask);
 			goto pageflags_fail;
 		}
-- 
2.25.1

--
Crash-utility mailing list
Crash-utility@xxxxxxxxxx
https://listman.redhat.com/mailman/listinfo/crash-utility
Contribution Guidelines: https://github.com/crash-utility/crash/wiki




[Index of Archives]     [Fedora Development]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [KDE Users]     [Fedora Tools]

 

Powered by Linux