diff options
Diffstat (limited to 'plugins-root')
-rw-r--r-- | plugins-root/check_icmp.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/plugins-root/check_icmp.c b/plugins-root/check_icmp.c index 98891f02..e45fdf60 100644 --- a/plugins-root/check_icmp.c +++ b/plugins-root/check_icmp.c | |||
@@ -1336,7 +1336,7 @@ add_target(char *arg) | |||
1336 | 1336 | ||
1337 | switch (address_family) { | 1337 | switch (address_family) { |
1338 | case -1: | 1338 | case -1: |
1339 | // -4 and -6 are not specified on cmdline | 1339 | /* -4 and -6 are not specified on cmdline */ |
1340 | address_family = AF_INET; | 1340 | address_family = AF_INET; |
1341 | sin = (struct sockaddr_in *)&ip; | 1341 | sin = (struct sockaddr_in *)&ip; |
1342 | result = inet_pton(address_family, arg, &sin->sin_addr); | 1342 | result = inet_pton(address_family, arg, &sin->sin_addr); |
@@ -1347,6 +1347,10 @@ add_target(char *arg) | |||
1347 | result = inet_pton(address_family, arg, &sin6->sin6_addr); | 1347 | result = inet_pton(address_family, arg, &sin6->sin6_addr); |
1348 | } | 1348 | } |
1349 | #endif | 1349 | #endif |
1350 | /* If we don't find any valid addresses, we still don't know the address_family */ | ||
1351 | if ( result != 1) { | ||
1352 | address_family = -1; | ||
1353 | } | ||
1350 | break; | 1354 | break; |
1351 | case AF_INET: | 1355 | case AF_INET: |
1352 | sin = (struct sockaddr_in *)&ip; | 1356 | sin = (struct sockaddr_in *)&ip; |
@@ -1367,7 +1371,11 @@ add_target(char *arg) | |||
1367 | else { | 1371 | else { |
1368 | errno = 0; | 1372 | errno = 0; |
1369 | memset(&hints, 0, sizeof(hints)); | 1373 | memset(&hints, 0, sizeof(hints)); |
1370 | hints.ai_family = AF_UNSPEC; | 1374 | if (address_family == -1) { |
1375 | hints.ai_family = AF_UNSPEC; | ||
1376 | } else { | ||
1377 | hints.ai_family = address_family == AF_INET ? PF_INET : PF_INET6; | ||
1378 | } | ||
1371 | hints.ai_socktype = SOCK_RAW; | 1379 | hints.ai_socktype = SOCK_RAW; |
1372 | if((error = getaddrinfo(arg, NULL, &hints, &res)) != 0) { | 1380 | if((error = getaddrinfo(arg, NULL, &hints, &res)) != 0) { |
1373 | errno = 0; | 1381 | errno = 0; |