[Crash-utility] [PATCH v3 3/4] Set name_hash_next field to be NULL for the newly installed elements

Tao Liu ltao at redhat.com
Tue Sep 14 09:01:53 UTC 2021


The newly installed element may contain junk data in the name_hash_next
field. If it does, it will corrupt the hash table. Thus name_hash_next
field should be set to NULL when the element is installed successfully
into the hash table.

Signed-off-by: Tao Liu <ltao at redhat.com>
---
 symbols.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/symbols.c b/symbols.c
index 44415da..f8b4998 100644
--- a/symbols.c
+++ b/symbols.c
@@ -1164,6 +1164,7 @@ symname_hash_install(struct syment *table[], struct syment *spn)
 
 	if ((sp = table[index]) == NULL) {
 		table[index] = spn;
+		spn->name_hash_next = NULL;
 	} else {
 		while (sp) {
 	        	if (STREQ(sp->name, spn->name)) {
@@ -1174,6 +1175,7 @@ symname_hash_install(struct syment *table[], struct syment *spn)
 				sp = sp->name_hash_next;
 			else {
 				sp->name_hash_next = spn;
+				spn->name_hash_next = NULL;
 				break;
 			}
 		}
-- 
2.29.2




More information about the Crash-utility mailing list