From 892da10a29dc99c8f8adc669319650c2d3a6f1eb Mon Sep 17 00:00:00 2001 From: Jakub Zawadzki Date: Thu, 5 May 2011 16:41:52 +0000 Subject: Subtract (not add!) preamble length from remaining buffer length. svn path=/trunk/; revision=36998 --- epan/address_to_str.c | 5 +++-- 1 file 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); -- cgit v1.2.1