summaryrefslogtreecommitdiff
path: root/arch/sandbox/cpu/eth-raw-os.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/sandbox/cpu/eth-raw-os.c')
-rw-r--r--arch/sandbox/cpu/eth-raw-os.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/arch/sandbox/cpu/eth-raw-os.c b/arch/sandbox/cpu/eth-raw-os.c
index b76a7319aee..ab64f6e2109 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,
@@ -194,7 +198,8 @@ int sandbox_eth_raw_os_send(void *packet, int length,
addr.sin_family = AF_INET;
addr.sin_port = udph->source;
addr.sin_addr.s_addr = iph->saddr;
- retval = bind(priv->local_bind_sd, &addr, sizeof(addr));
+ retval = bind(priv->local_bind_sd, (struct sockaddr *)&addr,
+ sizeof(addr));
if (retval < 0)
printf("Failed to bind: %d %s\n", errno,
strerror(errno));