Skip to content

Commit

Permalink
fix compile warning with GCC8
Browse files Browse the repository at this point in the history
  • Loading branch information
Zane authored Jul 6, 2018
1 parent ead13d7 commit 117dd05
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/netutils.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 85,8 @@ setinterface(int socket_fd, const char *interface_name)
{
struct ifreq interface;
memset(&interface, 0, sizeof(struct ifreq));
strncpy(interface.ifr_name, interface_name, IFNAMSIZ);
strncpy(interface.ifr_name, interface_name, IFNAMSIZ - 1);
interface.ifr_name[IFNAMSIZ - 1] = '\0';
int res = setsockopt(socket_fd, SOL_SOCKET, SO_BINDTODEVICE, &interface,
sizeof(struct ifreq));
return res;
Expand Down

0 comments on commit 117dd05

Please sign in to comment.