diff options
author | João Valverde <joao.valverde@tecnico.ulisboa.pt> | 2017-10-26 08:51:55 +0100 |
---|---|---|
committer | João Valverde <j@v6e.pt> | 2017-10-26 14:39:00 +0000 |
commit | ac804b59e242c57e225c390eb8d6bec359a7003f (patch) | |
tree | 914f047f0e08d253c284380b6a4960cabd2e2c69 /epan | |
parent | 296a36698b9ff2ab1beb3c21dc8409c3a276001c (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 'epan')
-rw-r--r-- | epan/address_types.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/epan/address_types.c b/epan/address_types.c index d6be4e63cf..8b43fa7469 100644 --- a/epan/address_types.c +++ b/epan/address_types.c @@ -439,11 +439,14 @@ static int ib_addr_to_str( const address *addr, gchar *buf, int buf_len){ if (addr->len >= 16) { /* GID is 128bits */ #define PREAMBLE_STR_LEN ((int)(sizeof("GID: ") - 1)) - g_strlcpy(buf, "GID: ", buf_len); - if (buf_len < PREAMBLE_STR_LEN || - ws_inet_ntop6(addr->data, buf + PREAMBLE_STR_LEN, - buf_len - PREAMBLE_STR_LEN) == NULL ) /* Returns NULL if no space and does not touch buf */ + gchar addr_buf[WS_INET6_ADDRSTRLEN]; + + ws_inet_ntop6(addr->data, addr_buf, sizeof(addr_buf)); + if (buf_len < PREAMBLE_STR_LEN + (int)strlen(addr_buf) + 1) { g_strlcpy(buf, BUF_TOO_SMALL_ERR, buf_len); /* Let the unexpected value alert user */ + } else { + g_snprintf(buf, buf_len, "GID: %s", addr_buf); + } } else { /* this is a LID (16 bits) */ guint16 lid_number; |