From e1ef732c11da520262476b782bc73bfaf6e9ef1d Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Sat, 28 Oct 2017 22:50:33 -0700 Subject: Get rid of MAX_IP_STR_LEN and MAX_IP6_STR_LEN. We have WS_INET_ADDRSTRLEN and WS_INET6_ADDRSTRLEN; use them. Change-Id: Idade0da9fae70d891901acd787b06d21e2ddbc5f Reviewed-on: https://code.wireshark.org/review/24156 Reviewed-by: Guy Harris --- epan/addr_resolv.c | 4 ++-- epan/address_types.c | 4 ++-- epan/dissectors/packet-tcp.c | 4 ++-- epan/dissectors/packet-udp.c | 4 ++-- epan/dissectors/packet-wccp.c | 2 +- epan/ftypes/ftype-ipv4.c | 4 ++-- epan/ftypes/ftype-ipv6.c | 2 +- epan/to_str.c | 2 +- epan/to_str.h | 2 -- ui/cli/tap-follow.c | 2 +- 10 files changed, 14 insertions(+), 16 deletions(-) diff --git a/epan/addr_resolv.c b/epan/addr_resolv.c index 77df65c036..bc14ec5ff9 100644 --- a/epan/addr_resolv.c +++ b/epan/addr_resolv.c @@ -786,12 +786,12 @@ fill_dummy_ip4(const guint addr, hashipv4_t* volatile tp) if (0 != subnet_entry.mask) { /* Print name, then '.' then IP address after subnet mask */ guint32 host_addr; - gchar buffer[MAX_IP_STR_LEN]; + gchar buffer[WS_INET_ADDRSTRLEN]; gchar* paddr; gsize i; host_addr = addr & (~(guint32)subnet_entry.mask); - ip_to_str_buf((guint8 *)&host_addr, buffer, MAX_IP_STR_LEN); + ip_to_str_buf((guint8 *)&host_addr, buffer, WS_INET_ADDRSTRLEN); paddr = buffer; /* Skip to first octet that is not totally masked diff --git a/epan/address_types.c b/epan/address_types.c index 8b43fa7469..e2ad4a2b70 100644 --- a/epan/address_types.c +++ b/epan/address_types.c @@ -214,7 +214,7 @@ static int ipv4_to_str(const address* addr, gchar *buf, int buf_len) static int ipv4_str_len(const address* addr _U_) { - return MAX_IP_STR_LEN; + return WS_INET_ADDRSTRLEN; } static const char* ipv4_col_filter_str(const address* addr _U_, gboolean is_src) @@ -253,7 +253,7 @@ static int ipv6_to_str(const address* addr, gchar *buf, int buf_len) static int ipv6_str_len(const address* addr _U_) { - return MAX_IP6_STR_LEN; + return WS_INET6_ADDRSTRLEN; } static const char* ipv6_col_filter_str(const address* addr _U_, gboolean is_src) diff --git a/epan/dissectors/packet-tcp.c b/epan/dissectors/packet-tcp.c index 9ddd88e020..325c81ba3b 100644 --- a/epan/dissectors/packet-tcp.c +++ b/epan/dissectors/packet-tcp.c @@ -935,8 +935,8 @@ gchar* tcp_follow_index_filter(int stream) gchar* tcp_follow_address_filter(address* src_addr, address* dst_addr, int src_port, int dst_port) { const gchar *ip_version = src_addr->type == AT_IPv6 ? "v6" : ""; - gchar src_addr_str[MAX_IP6_STR_LEN]; - gchar dst_addr_str[MAX_IP6_STR_LEN]; + gchar src_addr_str[WS_INET6_ADDRSTRLEN]; + gchar dst_addr_str[WS_INET6_ADDRSTRLEN]; address_to_str_buf(src_addr, src_addr_str, sizeof(src_addr_str)); address_to_str_buf(dst_addr, dst_addr_str, sizeof(dst_addr_str)); diff --git a/epan/dissectors/packet-udp.c b/epan/dissectors/packet-udp.c index 9cc5d13377..aa2f02b07e 100644 --- a/epan/dissectors/packet-udp.c +++ b/epan/dissectors/packet-udp.c @@ -450,8 +450,8 @@ static gchar* udp_follow_index_filter(int stream) static gchar* udp_follow_address_filter(address* src_addr, address* dst_addr, int src_port, int dst_port) { const gchar *ip_version = src_addr->type == AT_IPv6 ? "v6" : ""; - gchar src_addr_str[MAX_IP6_STR_LEN]; - gchar dst_addr_str[MAX_IP6_STR_LEN]; + gchar src_addr_str[WS_INET6_ADDRSTRLEN]; + gchar dst_addr_str[WS_INET6_ADDRSTRLEN]; address_to_str_buf(src_addr, src_addr_str, sizeof(src_addr_str)); address_to_str_buf(dst_addr, dst_addr_str, sizeof(dst_addr_str)); diff --git a/epan/dissectors/packet-wccp.c b/epan/dissectors/packet-wccp.c index b500e16810..d4f59ba526 100644 --- a/epan/dissectors/packet-wccp.c +++ b/epan/dissectors/packet-wccp.c @@ -700,7 +700,7 @@ static proto_item* wccp_add_ipaddress_item(proto_tree* tree, int hf_index, int h return proto_tree_add_ipv4_format(tree, hf_index, tvb, offset, length, host_addr, "INVALID IP family"); } -#define WCCP_IP_MAX_LENGTH (MAX_IP_STR_LEN > 46 ? MAX_IP_STR_LEN : 46) +#define WCCP_IP_MAX_LENGTH (WS_INET_ADDRSTRLEN > 46 ? WS_INET_ADDRSTRLEN : 46) static const gchar * decode_wccp_encoded_address(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, diff --git a/epan/ftypes/ftype-ipv4.c b/epan/ftypes/ftype-ipv4.c index 00a085ad21..c07392ecc6 100644 --- a/epan/ftypes/ftype-ipv4.c +++ b/epan/ftypes/ftype-ipv4.c @@ -116,12 +116,12 @@ val_repr_len(fvalue_t *fv _U_, ftrepr_t rtype _U_, int field_display _U_) return 15; } -/* We're assuming the buffer is at least MAX_IP_STR_LEN (16 bytes) */ +/* We're assuming the buffer is at least WS_INET_ADDRSTRLEN (16 bytes) */ static void val_to_repr(fvalue_t *fv, ftrepr_t rtype _U_, int field_display _U_, char *buf, unsigned int size _U_) { guint32 ipv4_net_order = g_htonl(fv->value.ipv4.addr); - ip_to_str_buf((guint8*)&ipv4_net_order, buf, MAX_IP_STR_LEN); + ip_to_str_buf((guint8*)&ipv4_net_order, buf, WS_INET_ADDRSTRLEN); } diff --git a/epan/ftypes/ftype-ipv6.c b/epan/ftypes/ftype-ipv6.c index fe51b77c29..a66a83d2ec 100644 --- a/epan/ftypes/ftype-ipv6.c +++ b/epan/ftypes/ftype-ipv6.c @@ -94,7 +94,7 @@ ipv6_from_unparsed(fvalue_t *fv, const char *s, gboolean allow_partial_value _U_ static int ipv6_repr_len(fvalue_t *fv _U_, ftrepr_t rtype _U_, int field_display _U_) { - return MAX_IP6_STR_LEN; + return WS_INET6_ADDRSTRLEN; } static void diff --git a/epan/to_str.c b/epan/to_str.c index 3785256156..4c59ef9681 100644 --- a/epan/to_str.c +++ b/epan/to_str.c @@ -1009,7 +1009,7 @@ ip_to_str_buf(const guint8 *ad, gchar *buf, const int buf_len) register gchar const *p; register gchar *b=buf; - if (buf_len < MAX_IP_STR_LEN) { + if (buf_len < WS_INET_ADDRSTRLEN) { g_strlcpy(buf, BUF_TOO_SMALL_ERR, buf_len); /* Let the unexpected value alert user */ return; } diff --git a/epan/to_str.h b/epan/to_str.h index 9c58533784..0a91d59c70 100644 --- a/epan/to_str.h +++ b/epan/to_str.h @@ -34,8 +34,6 @@ #include "wmem/wmem.h" #define GUID_STR_LEN 37 -#define MAX_IP_STR_LEN 16 -#define MAX_IP6_STR_LEN WS_INET6_ADDRSTRLEN #define MAX_ADDR_STR_LEN 256 #define VINES_ADDR_LEN 6 #define EUI64_STR_LEN 24 diff --git a/ui/cli/tap-follow.c b/ui/cli/tap-follow.c index e625092ff0..ba77398977 100644 --- a/ui/cli/tap-follow.c +++ b/ui/cli/tap-follow.c @@ -171,7 +171,7 @@ static void follow_draw(void *contextp) follow_info_t *follow_info = (follow_info_t*)contextp; cli_follow_info_t* cli_follow_info = (cli_follow_info_t*)follow_info->gui_data; - gchar buf[MAX_IP6_STR_LEN]; + gchar buf[WS_INET6_ADDRSTRLEN]; guint32 global_client_pos = 0, global_server_pos = 0; guint32 *global_pos; guint32 ii, jj; -- cgit v1.2.3