summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: bd84273)
raw | patch | inline | side by side (parent: bd84273)
author | Holger Weiss <hweiss@users.sourceforge.net> | |
Thu, 26 Jul 2007 00:46:42 +0000 (00:46 +0000) | ||
committer | Holger Weiss <hweiss@users.sourceforge.net> | |
Thu, 26 Jul 2007 00:46:42 +0000 (00:46 +0000) |
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1764 f882894a-f735-0410-b71e-b25c423dba1c
plugins-root/check_dhcp.c | patch | blob | history |
index 904d43ef8e4f29225403694fd0827a16a77f92c4..db673893ffb1d50a018e76740ee717bdfa89a1a8 100644 (file)
#if defined(__linux__)
struct ifreq ifr;
#if defined(__linux__)
struct ifreq ifr;
- strncpy((char *)&ifr.ifr_name,interface_name,sizeof(ifr.ifr_name));
+ strncpy((char *)&ifr.ifr_name,interface_name,sizeof(ifr.ifr_name)-1);
+ ifr.ifr_name[sizeof(ifr.ifr_name)-1]='\0';
/* try and grab hardware address of requested interface */
if(ioctl(sock,SIOCGIFHWADDR,&ifr)<0){
/* try and grab hardware address of requested interface */
if(ioctl(sock,SIOCGIFHWADDR,&ifr)<0){
/* bind socket to interface */
#if defined(__linux__)
/* bind socket to interface */
#if defined(__linux__)
- strncpy(interface.ifr_ifrn.ifrn_name,network_interface_name,IFNAMSIZ);
+ strncpy(interface.ifr_ifrn.ifrn_name,network_interface_name,IFNAMSIZ-1);
+ interface.ifr_ifrn.ifrn_name[IFNAMSIZ-1]='\0';
if(setsockopt(sock,SOL_SOCKET,SO_BINDTODEVICE,(char *)&interface,sizeof(interface))<0){
printf(_("Error: Could not bind socket to interface %s. Check your privileges...\n"),network_interface_name);
exit(STATE_UNKNOWN);
}
#else
if(setsockopt(sock,SOL_SOCKET,SO_BINDTODEVICE,(char *)&interface,sizeof(interface))<0){
printf(_("Error: Could not bind socket to interface %s. Check your privileges...\n"),network_interface_name);
exit(STATE_UNKNOWN);
}
#else
- strncpy(interface.ifr_name,network_interface_name,IFNAMSIZ);
+ strncpy(interface.ifr_name,network_interface_name,IFNAMSIZ-1);
+ interface.ifr_name[IFNAMSIZ-1]='\0';
#endif
/* bind the socket */
#endif
/* bind the socket */