aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ll_map.c
diff options
context:
space:
mode:
authorPhil Sutter <phil@nwl.cc>2017-08-24 11:51:50 +0200
committerStephen Hemminger <stephen@networkplumber.org>2017-08-24 14:53:14 -0700
commit4b9e91782269fc871d158ed4f11bfcfe4e3b8bf7 (patch)
tree6a869a90de83dd352e0e4a349e9df7c42a3acca0 /lib/ll_map.c
parent56270e54661e8ca51d4b3661b9f9bb12a0a40d95 (diff)
downloadplatform_external_iproute2-4b9e91782269fc871d158ed4f11bfcfe4e3b8bf7.tar.gz
platform_external_iproute2-4b9e91782269fc871d158ed4f11bfcfe4e3b8bf7.tar.bz2
platform_external_iproute2-4b9e91782269fc871d158ed4f11bfcfe4e3b8bf7.zip
lib/ll_map: Choose size of new cache items at run-time
Instead of having a fixed buffer of 16 bytes for the interface name, tailor size of new ll_cache entry using the interface name's actual length. This also makes sure the following call to strcpy() is safe. Signed-off-by: Phil Sutter <phil@nwl.cc>
Diffstat (limited to 'lib/ll_map.c')
-rw-r--r--lib/ll_map.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/ll_map.c b/lib/ll_map.c
index 4e4556c9..70684b02 100644
--- a/lib/ll_map.c
+++ b/lib/ll_map.c
@@ -30,7 +30,7 @@ struct ll_cache {
unsigned flags;
unsigned index;
unsigned short type;
- char name[IFNAMSIZ];
+ char name[];
};
#define IDXMAP_SIZE 1024
@@ -120,7 +120,7 @@ int ll_remember_index(const struct sockaddr_nl *who,
return 0;
}
- im = malloc(sizeof(*im));
+ im = malloc(sizeof(*im) + strlen(ifname) + 1);
if (im == NULL)
return 0;
im->index = ifi->ifi_index;