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>
This commit is contained in:
parent
56270e5466
commit
4b9e917822
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in New Issue