aboutsummaryrefslogtreecommitdiffstats
path: root/packet-ieee80211.c
diff options
context:
space:
mode:
authorGerald Combs <gerald@wireshark.org>2003-05-24 17:45:10 +0000
committerGerald Combs <gerald@wireshark.org>2003-05-24 17:45:10 +0000
commit356ddbd284075257edda1b7a8c77fe9539f817b5 (patch)
tree29e407f5a20819fdc0040e2bb301f6240053c46f /packet-ieee80211.c
parent4d5243dcc74a17157213fef24d37e9fdbbb693bf (diff)
Fix instances where the return value of snprintf() was being checked for -1,
but not for <buf_size> or greater. Discovered by Timo Sirainen. svn path=/trunk/; revision=7731
Diffstat (limited to 'packet-ieee80211.c')
-rw-r--r--packet-ieee80211.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/packet-ieee80211.c b/packet-ieee80211.c
index 9e3adc0f32..512cd9467d 100644
--- a/packet-ieee80211.c
+++ b/packet-ieee80211.c
@@ -3,7 +3,7 @@
* Copyright 2000, Axis Communications AB
* Inquiries/bugreports should be sent to Johan.Jorgensen@axis.com
*
- * $Id: packet-ieee80211.c,v 1.86 2003/04/27 20:57:58 deniel Exp $
+ * $Id: packet-ieee80211.c,v 1.87 2003/05/24 17:45:10 gerald Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -755,9 +755,9 @@ add_tagged_field (proto_tree * tree, tvbuff_t * tvb, int offset)
ret = snprintf (out_buff + n, SHORT_STR - n, "%2.1f%s ",
(tag_data_ptr[i] & 0x7F) * 0.5,
(tag_data_ptr[i] & 0x80) ? "(B)" : "");
- if (ret == -1) {
+ if (ret == -1 || ret >= SHORT_STR - n) {
/* Some versions of snprintf return -1 if they'd truncate
- the output. */
+ the output. Others return <buf_size> or greater. */
break;
}
n += ret;
@@ -765,6 +765,7 @@ add_tagged_field (proto_tree * tree, tvbuff_t * tvb, int offset)
if (n < SHORT_STR)
snprintf (out_buff + n, SHORT_STR - n, "[Mbit/sec]");
+ out_buff[SHORT_STR] = '\0';
proto_tree_add_string (tree, tag_interpretation, tvb, offset + 2,
tag_len, out_buff);
break;