diff options
| -rw-r--r-- | plugins-root/check_dhcp.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/plugins-root/check_dhcp.c b/plugins-root/check_dhcp.c index 904d43ef..db673893 100644 --- a/plugins-root/check_dhcp.c +++ b/plugins-root/check_dhcp.c | |||
| @@ -313,7 +313,8 @@ int get_hardware_address(int sock,char *interface_name){ | |||
| 313 | #if defined(__linux__) | 313 | #if defined(__linux__) |
| 314 | struct ifreq ifr; | 314 | struct ifreq ifr; |
| 315 | 315 | ||
| 316 | strncpy((char *)&ifr.ifr_name,interface_name,sizeof(ifr.ifr_name)); | 316 | strncpy((char *)&ifr.ifr_name,interface_name,sizeof(ifr.ifr_name)-1); |
| 317 | ifr.ifr_name[sizeof(ifr.ifr_name)-1]='\0'; | ||
| 317 | 318 | ||
| 318 | /* try and grab hardware address of requested interface */ | 319 | /* try and grab hardware address of requested interface */ |
| 319 | if(ioctl(sock,SIOCGIFHWADDR,&ifr)<0){ | 320 | if(ioctl(sock,SIOCGIFHWADDR,&ifr)<0){ |
| @@ -773,14 +774,16 @@ int create_dhcp_socket(void){ | |||
| 773 | 774 | ||
| 774 | /* bind socket to interface */ | 775 | /* bind socket to interface */ |
| 775 | #if defined(__linux__) | 776 | #if defined(__linux__) |
| 776 | strncpy(interface.ifr_ifrn.ifrn_name,network_interface_name,IFNAMSIZ); | 777 | strncpy(interface.ifr_ifrn.ifrn_name,network_interface_name,IFNAMSIZ-1); |
| 778 | interface.ifr_ifrn.ifrn_name[IFNAMSIZ-1]='\0'; | ||
| 777 | if(setsockopt(sock,SOL_SOCKET,SO_BINDTODEVICE,(char *)&interface,sizeof(interface))<0){ | 779 | if(setsockopt(sock,SOL_SOCKET,SO_BINDTODEVICE,(char *)&interface,sizeof(interface))<0){ |
| 778 | printf(_("Error: Could not bind socket to interface %s. Check your privileges...\n"),network_interface_name); | 780 | printf(_("Error: Could not bind socket to interface %s. Check your privileges...\n"),network_interface_name); |
| 779 | exit(STATE_UNKNOWN); | 781 | exit(STATE_UNKNOWN); |
| 780 | } | 782 | } |
| 781 | 783 | ||
| 782 | #else | 784 | #else |
| 783 | strncpy(interface.ifr_name,network_interface_name,IFNAMSIZ); | 785 | strncpy(interface.ifr_name,network_interface_name,IFNAMSIZ-1); |
| 786 | interface.ifr_name[IFNAMSIZ-1]='\0'; | ||
| 784 | #endif | 787 | #endif |
| 785 | 788 | ||
| 786 | /* bind the socket */ | 789 | /* bind the socket */ |
