diff options
| author | Tom Rini <[email protected]> | 2015-12-07 22:26:34 -0500 |
|---|---|---|
| committer | Simon Glass <[email protected]> | 2016-01-12 10:19:09 -0700 |
| commit | ab971e192adcf0a501c8998542ab116512c0c260 (patch) | |
| tree | b47989baa22ba66a336703e89a3c42d03f2c9313 | |
| parent | 66eaea6cd152a0dae5964930483f68d92047b2f5 (diff) | |
sandbox: eth-raw-os.c: Ensure that our interface name is not too long
Coverity notes that we do not ensure when we copy ifname we still have
space left to ensure NULL termination. As cannot control the size of
ifr_name we must make sure that our argument will not overflow the
buffer.
Reported-by: Coverity (CID 131094)
Cc: Simon Glass <[email protected]>
Signed-off-by: Tom Rini <[email protected]>
Reviewed-by: Simon Glass <[email protected]>
| -rw-r--r-- | arch/sandbox/cpu/eth-raw-os.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/arch/sandbox/cpu/eth-raw-os.c b/arch/sandbox/cpu/eth-raw-os.c index b76a7319aee..528865f5d3f 100644 --- a/arch/sandbox/cpu/eth-raw-os.c +++ b/arch/sandbox/cpu/eth-raw-os.c @@ -76,6 +76,10 @@ static int _raw_packet_start(const char *ifname, unsigned char *ethmac, printf("Failed to set promiscuous mode: %d %s\n" "Falling back to the old \"flags\" way...\n", errno, strerror(errno)); + if (strlen(ifname) >= IFNAMSIZ) { + printf("Interface name %s is too long.\n", ifname); + return -EINVAL; + } strncpy(ifr.ifr_name, ifname, IFNAMSIZ); if (ioctl(priv->sd, SIOCGIFFLAGS, &ifr) < 0) { printf("Failed to read flags: %d %s\n", errno, |
