|
|
99be8f |
From 6ab89ff96d59c90cd6227399a065d52cc38e0ee7 Mon Sep 17 00:00:00 2001
|
|
|
99be8f |
From: Andrea Claudi <aclaudi@redhat.com>
|
|
|
99be8f |
Date: Mon, 29 Apr 2019 20:08:08 +0200
|
|
|
99be8f |
Subject: [PATCH] lib/ll_map: Choose size of new cache items at run-time
|
|
|
99be8f |
|
|
|
99be8f |
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1465646
|
|
|
99be8f |
Upstream Status: iproute2.git commit 4b9e91782269f
|
|
|
99be8f |
|
|
|
99be8f |
commit 4b9e91782269fc871d158ed4f11bfcfe4e3b8bf7
|
|
|
99be8f |
Author: Phil Sutter <phil@nwl.cc>
|
|
|
99be8f |
Date: Thu Aug 24 11:51:50 2017 +0200
|
|
|
99be8f |
|
|
|
99be8f |
lib/ll_map: Choose size of new cache items at run-time
|
|
|
99be8f |
|
|
|
99be8f |
Instead of having a fixed buffer of 16 bytes for the interface name,
|
|
|
99be8f |
tailor size of new ll_cache entry using the interface name's actual
|
|
|
99be8f |
length. This also makes sure the following call to strcpy() is safe.
|
|
|
99be8f |
|
|
|
99be8f |
Signed-off-by: Phil Sutter <phil@nwl.cc>
|
|
|
99be8f |
---
|
|
|
99be8f |
lib/ll_map.c | 4 ++--
|
|
|
99be8f |
1 file changed, 2 insertions(+), 2 deletions(-)
|
|
|
99be8f |
|
|
|
99be8f |
diff --git a/lib/ll_map.c b/lib/ll_map.c
|
|
|
99be8f |
index 4e4556c9ac80b..70684b02042b6 100644
|
|
|
99be8f |
--- a/lib/ll_map.c
|
|
|
99be8f |
+++ b/lib/ll_map.c
|
|
|
99be8f |
@@ -30,7 +30,7 @@ struct ll_cache {
|
|
|
99be8f |
unsigned flags;
|
|
|
99be8f |
unsigned index;
|
|
|
99be8f |
unsigned short type;
|
|
|
99be8f |
- char name[IFNAMSIZ];
|
|
|
99be8f |
+ char name[];
|
|
|
99be8f |
};
|
|
|
99be8f |
|
|
|
99be8f |
#define IDXMAP_SIZE 1024
|
|
|
99be8f |
@@ -120,7 +120,7 @@ int ll_remember_index(const struct sockaddr_nl *who,
|
|
|
99be8f |
return 0;
|
|
|
99be8f |
}
|
|
|
99be8f |
|
|
|
99be8f |
- im = malloc(sizeof(*im));
|
|
|
99be8f |
+ im = malloc(sizeof(*im) + strlen(ifname) + 1);
|
|
|
99be8f |
if (im == NULL)
|
|
|
99be8f |
return 0;
|
|
|
99be8f |
im->index = ifi->ifi_index;
|
|
|
99be8f |
--
|
|
|
d30c09 |
2.21.0
|
|
|
99be8f |
|