buffer overflow in arp (RHBZ #164695)
authorJiri Popelka <jpopelka@redhat.com>
Wed, 7 Dec 2011 17:43:03 +0000 (18:43 +0100)
committerJiri Popelka <jpopelka@redhat.com>
Thu, 5 Jan 2012 11:22:43 +0000 (12:22 +0100)
Steps to Reproduce:
1. arp -s 172.16.1.3 00:80:c8:04:05:06 -D eth0

arp.c

diff --git a/arp.c b/arp.c
index 8a376ec..72e87d6 100644 (file)
--- a/arp.c
+++ b/arp.c
@@ -243,7 +243,7 @@ static int arp_getdevhw(char *ifname, struct sockaddr *sa, struct hwtype *hw)
     struct ifreq ifr;
     struct hwtype *xhw;
 
-    strcpy(ifr.ifr_name, ifname);
+    strncpy(ifr.ifr_name, ifname, IFNAMSIZ);
     if (ioctl(sockfd, SIOCGIFHWADDR, &ifr) < 0) {
        fprintf(stderr, _("arp: cant get HW-Address for `%s': %s.\n"), ifname, strerror(errno));
        return (-1);