naccyde / rpms / iproute

Forked from rpms/iproute 7 months ago
Clone

Blame SOURCES/0110-lib-ll_map-Choose-size-of-new-cache-items-at-run-tim.patch

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