]> git.sur5r.net Git - u-boot/blobdiff - arch/sandbox/cpu/eth-raw-os.c
sandbox: eth-raw-os.c: Ensure that our interface name is not too long
[u-boot] / arch / sandbox / cpu / eth-raw-os.c
index b76a7319aeeb762c96a1ef71cfa5e61ed7a2e0e7..528865f5d3fb9df30cb5cd91b0de52866e178684 100644 (file)
@@ -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,