aboutsummaryrefslogtreecommitdiffstats
path: root/epan
diff options
context:
space:
mode:
authordarkjames <darkjames@f5534014-38df-0310-8fa8-9805f1628bb7>2011-05-05 16:41:52 +0000
committerdarkjames <darkjames@f5534014-38df-0310-8fa8-9805f1628bb7>2011-05-05 16:41:52 +0000
commitb0d7d38b0f7ab0a59663b99e57eba102b0c4697e (patch)
treedc985d817fb032892dc6ee8a3301856d0499c54f /epan
parent4dca81fc137829382ac91fe700e37f7a73d05e88 (diff)
Subtract (not add!) preamble length from remaining buffer length.
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@36998 f5534014-38df-0310-8fa8-9805f1628bb7
Diffstat (limited to 'epan')
-rw-r--r--epan/address_to_str.c5
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);