33 lines
927 B
Diff
33 lines
927 B
Diff
|
|
From 225f74761b091e51444cf1f9686547f3c42e44b3 Mon Sep 17 00:00:00 2001
|
||
|
|
From: Denis Kirjanov <kirjanov@gmail.com>
|
||
|
|
Date: Wed, 13 Nov 2024 13:53:49 +0300
|
||
|
|
Subject: [PATCH] lib: names: check calloc return value in db_names_alloc
|
||
|
|
|
||
|
|
db_names_load() may crash since it touches the
|
||
|
|
hash member. Fix it by checking the return value
|
||
|
|
|
||
|
|
Signed-off-by: Denis Kirjanov <kirjanov@gmail.com>
|
||
|
|
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
|
||
|
|
|
||
|
|
Conflict: NA
|
||
|
|
Reference: https://github.com/iproute2/iproute2/commit/225f74761b091e51444cf1f9686547f3c42e44b3
|
||
|
|
---
|
||
|
|
lib/names.c | 4 ++++
|
||
|
|
1 file changed, 4 insertions(+)
|
||
|
|
|
||
|
|
diff --git a/lib/names.c b/lib/names.c
|
||
|
|
index cbfa971ff..4ecae92b9 100644
|
||
|
|
--- a/lib/names.c
|
||
|
|
+++ b/lib/names.c
|
||
|
|
@@ -55,6 +55,10 @@ struct db_names *db_names_alloc(void)
|
||
|
|
|
||
|
|
db->size = MAX_ENTRIES;
|
||
|
|
db->hash = calloc(db->size, sizeof(struct db_entry *));
|
||
|
|
+ if (!db->hash) {
|
||
|
|
+ free(db);
|
||
|
|
+ return NULL;
|
||
|
|
+ }
|
||
|
|
|
||
|
|
return db;
|
||
|
|
}
|