diff options
-rw-r--r-- | epan/address_to_str.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/epan/address_to_str.c b/epan/address_to_str.c index e65aa0e220..0beb50882c 100644 --- a/epan/address_to_str.c +++ b/epan/address_to_str.c @@ -251,8 +251,9 @@ ib_addr_to_str_buf( const address *addr, gchar *buf, int buf_len){ if (addr->len >= 16) { /* GID is 128bits */ #define PREAMBLE_STR_LEN (sizeof("GID: ") - 1) g_snprintf(buf,buf_len,"GID: "); - if ( inet_ntop(AF_INET6, addr->data, buf + PREAMBLE_STR_LEN, - buf_len + PREAMBLE_STR_LEN) == NULL ) /* Returns NULL if no space and does not touch buf */ + if (buf_len < (int)PREAMBLE_STR_LEN || + inet_ntop(AF_INET6, addr->data, buf + PREAMBLE_STR_LEN, + buf_len - PREAMBLE_STR_LEN) == NULL ) /* Returns NULL if no space and does not touch buf */ g_snprintf ( buf, buf_len, BUF_TOO_SMALL_ERR ); /* Let the unexpected value alert user */ } else { /* this is a LID (16 bits) */ guint16 lid_number = *((guint16*) addr->data); |