corrected string copy memory overwrite.

This commit is contained in:
skarg
2005-04-02 14:09:15 +00:00
parent 15768f0eac
commit 47c2286a34
+1 -1
View File
@@ -130,7 +130,7 @@ static int ethernet_bind(struct sockaddr *eth_addr, char *interface_name)
/* Clear the memory before copying */
memset(eth_addr->sa_data, '\0', sizeof(eth_addr->sa_data));
/* Strcpy the interface name into the address */
strncpy(eth_addr->sa_data, interface_name, IFNAMSIZ);
strncpy(eth_addr->sa_data, interface_name, sizeof(eth_addr->sa_data)-1);
fprintf(stderr,"ethernet: binding \"%s\"\n",eth_addr->sa_data);
/* Attempt to bind the socket to the interface */
if (bind(sock_fd, eth_addr, sizeof(struct sockaddr)) != 0)