Blame SOURCES/0027-Fix-segmentation-fault-in-page_flags_init_from_pagef.patch

3ce5e9
From cdcf2d3f4c69ffa8a29b70120ee4fca6e390123b Mon Sep 17 00:00:00 2001
3ce5e9
From: Matias Ezequiel Vara Larsen <matiasevara@gmail.com>
3ce5e9
Date: Mon, 24 Oct 2022 11:35:29 +0200
3ce5e9
Subject: [PATCH 27/28] Fix segmentation fault in
3ce5e9
 page_flags_init_from_pageflag_names()
3ce5e9
3ce5e9
When read_string() fails in page_flags_init_from_pageflag_names(),
3ce5e9
error() dereferences the name variable to print the string that the
3ce5e9
variable points to. However, name points to a string that is not in
3ce5e9
crash's memory-space thus triggering a segmentation fault.
3ce5e9
3ce5e9
This patch replaces "%s" in the error message with "%lx" so the address
3ce5e9
is printed instead.  Also replaces "%ld" for mask with "%lx".
3ce5e9
3ce5e9
[ kh: changed the conversion specifiers and commit message ]
3ce5e9
3ce5e9
Signed-off-by: Matias Ezequiel Vara Larsen <matias.vara@vates.fr>
3ce5e9
Signed-off-by: Kazuhito Hagio <k-hagio-ab@nec.com>
3ce5e9
Signed-off-by: Lianbo Jiang <lijiang@redhat.com>
3ce5e9
---
3ce5e9
 memory.c | 2 +-
3ce5e9
 1 file changed, 1 insertion(+), 1 deletion(-)
3ce5e9
3ce5e9
diff --git a/memory.c b/memory.c
3ce5e9
index ff6b571361eb..ddbf458277f0 100644
3ce5e9
--- a/memory.c
3ce5e9
+++ b/memory.c
3ce5e9
@@ -6599,7 +6599,7 @@ page_flags_init_from_pageflag_names(void)
3ce5e9
 		}
3ce5e9
 
3ce5e9
 		if (!read_string((ulong)name, namebuf, BUFSIZE-1)) {
3ce5e9
-			error(INFO, "failed to read pageflag_names entry (i: %d  name: \"%s\"  mask: %ld)\n",
3ce5e9
+			error(INFO, "failed to read pageflag_names entry (i: %d  name: %lx  mask: %lx)\n",
3ce5e9
 				i, name, mask);
3ce5e9
 			goto pageflags_fail;
3ce5e9
 		}
3ce5e9
-- 
3ce5e9
2.37.1
3ce5e9