diff options
author | Gerald Combs <gerald@wireshark.org> | 2003-05-24 17:45:10 +0000 |
---|---|---|
committer | Gerald Combs <gerald@wireshark.org> | 2003-05-24 17:45:10 +0000 |
commit | 356ddbd284075257edda1b7a8c77fe9539f817b5 (patch) | |
tree | 29e407f5a20819fdc0040e2bb301f6240053c46f /packet-ieee80211.c | |
parent | 4d5243dcc74a17157213fef24d37e9fdbbb693bf (diff) | |
download | wireshark-356ddbd284075257edda1b7a8c77fe9539f817b5.tar.gz wireshark-356ddbd284075257edda1b7a8c77fe9539f817b5.tar.bz2 wireshark-356ddbd284075257edda1b7a8c77fe9539f817b5.zip |
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.c | 7 |
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; |