diff options
| author | Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> | 2023-07-11 23:08:31 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-07-11 23:08:31 +0200 |
| commit | e4b6e83264e7f948a868d89229c28bcccd98699f (patch) | |
| tree | d5046000910b42d18c6fe42634f9cec9e96d9c0e /plugins-root/check_icmp.c | |
| parent | 9ef6660cab8eb2b017323b9e000cb3560f07886b (diff) | |
| parent | 65aa35d1afdea2570309efc7a08050504a53f091 (diff) | |
| download | monitoring-plugins-e4b6e83.tar.gz | |
Merge branch 'master' into compiler_warning_part_6
Diffstat (limited to 'plugins-root/check_icmp.c')
| -rw-r--r-- | plugins-root/check_icmp.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/plugins-root/check_icmp.c b/plugins-root/check_icmp.c index 9ceb35b2..1d47e9fc 100644 --- a/plugins-root/check_icmp.c +++ b/plugins-root/check_icmp.c | |||
| @@ -1432,15 +1432,20 @@ get_ip_address(const char *ifname) | |||
| 1432 | { | 1432 | { |
| 1433 | // TODO: Rewrite this so the function return an error and we exit somewhere else | 1433 | // TODO: Rewrite this so the function return an error and we exit somewhere else |
| 1434 | struct sockaddr_in ip; | 1434 | struct sockaddr_in ip; |
| 1435 | ip.sin_addr.s_addr = 0; // Fake initialization to make compiler happy | ||
| 1435 | #if defined(SIOCGIFADDR) | 1436 | #if defined(SIOCGIFADDR) |
| 1436 | struct ifreq ifr; | 1437 | struct ifreq ifr; |
| 1437 | 1438 | ||
| 1438 | strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name) - 1); | 1439 | strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name) - 1); |
| 1440 | |||
| 1439 | ifr.ifr_name[sizeof(ifr.ifr_name) - 1] = '\0'; | 1441 | ifr.ifr_name[sizeof(ifr.ifr_name) - 1] = '\0'; |
| 1442 | |||
| 1440 | if(ioctl(icmp_sock, SIOCGIFADDR, &ifr) == -1) | 1443 | if(ioctl(icmp_sock, SIOCGIFADDR, &ifr) == -1) |
| 1441 | crash("Cannot determine IP address of interface %s", ifname); | 1444 | crash("Cannot determine IP address of interface %s", ifname); |
| 1445 | |||
| 1442 | memcpy(&ip, &ifr.ifr_addr, sizeof(ip)); | 1446 | memcpy(&ip, &ifr.ifr_addr, sizeof(ip)); |
| 1443 | #else | 1447 | #else |
| 1448 | (void) ifname; | ||
| 1444 | errno = 0; | 1449 | errno = 0; |
| 1445 | crash("Cannot get interface IP address on this platform."); | 1450 | crash("Cannot get interface IP address on this platform."); |
| 1446 | #endif | 1451 | #endif |
