aboutsummaryrefslogtreecommitdiffstats
path: root/dumpcap.c
diff options
context:
space:
mode:
authorJoão Valverde <joao.valverde@tecnico.ulisboa.pt>2017-10-26 08:51:55 +0100
committerJoão Valverde <j@v6e.pt>2017-10-26 14:39:00 +0000
commitac804b59e242c57e225c390eb8d6bec359a7003f (patch)
tree914f047f0e08d253c284380b6a4960cabd2e2c69 /dumpcap.c
parent296a36698b9ff2ab1beb3c21dc8409c3a276001c (diff)
Improve our inet_ntop() wrapper
Also fix buffer length define, as it is not guaranteed to be 46 on Windows (it never was guaranteed anyway for the libc implementation, but the likelyhood of being greater was small). Change-Id: I2db705d86f825765ed32ec70b8d22058b5d629e8 Reviewed-on: https://code.wireshark.org/review/24074 Reviewed-by: João Valverde <j@v6e.pt>
Diffstat (limited to 'dumpcap.c')
-rw-r--r--dumpcap.c17
1 files changed, 3 insertions, 14 deletions
diff --git a/dumpcap.c b/dumpcap.c
index 3ee8bef878..492d5bb57b 100644
--- a/dumpcap.c
+++ b/dumpcap.c
@@ -818,7 +818,6 @@ capture_interface_list(int *err, char **err_str, void(*update_cb)(void) _U_)
return get_interface_list(err, err_str);
}
-#define ADDRSTRLEN 46 /* Covers IPv4 & IPv6 */
/*
* Output a machine readable list of the interfaces
* This list is retrieved by the sync_interface_list_open() function
@@ -832,7 +831,7 @@ print_machine_readable_interfaces(GList *if_list)
if_info_t *if_info;
GSList *addr;
if_addr_t *if_addr;
- char addr_str[ADDRSTRLEN];
+ char addr_str[WS_INET6_ADDRSTRLEN];
if (capture_child) {
/* Let our parent know we succeeded. */
@@ -872,20 +871,10 @@ print_machine_readable_interfaces(GList *if_list)
if_addr = (if_addr_t *)addr->data;
switch(if_addr->ifat_type) {
case IF_AT_IPv4:
- if (ws_inet_ntop4(&if_addr->addr.ip4_addr, addr_str,
- ADDRSTRLEN)) {
- printf("%s", addr_str);
- } else {
- printf("<unknown IPv4>");
- }
+ printf("%s", ws_inet_ntop4(&if_addr->addr.ip4_addr, addr_str, sizeof(addr_str)));
break;
case IF_AT_IPv6:
- if (ws_inet_ntop6(&if_addr->addr.ip6_addr,
- addr_str, ADDRSTRLEN)) {
- printf("%s", addr_str);
- } else {
- printf("<unknown IPv6>");
- }
+ printf("%s", ws_inet_ntop6(&if_addr->addr.ip6_addr, addr_str, sizeof(addr_str)));
break;
default:
printf("<type unknown %i>", if_addr->ifat_type);