Sophie

Sophie

distrib > Fedora > 14 > x86_64 > by-pkgid > 0778169c613c655cac3f77c206d2ad44 > files > 2

macchanger-1.5.0-9.fc14.src.rpm

Fix buffer overlow (caught by FORTIFY_SOURCE) when too long device name is
specified as command line argument.

https://bugzilla.redhat.com/show_bug.cgi?id=641704

--- macchanger-1.5.0/src/netinfo.c.orig	2010-10-11 18:06:48.000000000 +0200
+++ macchanger-1.5.0/src/netinfo.c	2010-10-11 18:11:42.000000000 +0200
@@ -44,7 +44,8 @@ mc_net_info_new (const char *device)
 		return NULL;
 	}
 
-	strcpy (new->dev.ifr_name, device);
+	strncpy (new->dev.ifr_name, device, sizeof(new->dev.ifr_name));
+	new->dev.ifr_name[sizeof(new->dev.ifr_name)-1] = '\0';
 	if (ioctl(new->sock, SIOCGIFHWADDR, &new->dev) < 0) {
 		perror ("set device name");
 		free(new);