aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-bittorrent.c
diff options
context:
space:
mode:
authorwmeier <wmeier@f5534014-38df-0310-8fa8-9805f1628bb7>2011-01-31 21:23:35 +0000
committerwmeier <wmeier@f5534014-38df-0310-8fa8-9805f1628bb7>2011-01-31 21:23:35 +0000
commit4b83bfd8ac77b31ddff99b8975424dacbe6c38cf (patch)
tree7b424da6c5f12257eb3aca5fc16470bef98e71aa /epan/dissectors/packet-bittorrent.c
parent5673806c15ef2d288b47ceba98a1c42793ae18eb (diff)
Fix minor bug lookups of certain "peer ids" would fail.
The issue (in essence) For: char foo[][4] = {"abc", "defg", "hij"}; strlen(foo[1]) will be 7 and not 4 as expected; Detected via msvc level 4 warning: "array is too small to include a terminating null character" git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@35732 f5534014-38df-0310-8fa8-9805f1628bb7
Diffstat (limited to 'epan/dissectors/packet-bittorrent.c')
-rw-r--r--epan/dissectors/packet-bittorrent.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/epan/dissectors/packet-bittorrent.c b/epan/dissectors/packet-bittorrent.c
index 77cfae9aa0..ea00a4d392 100644
--- a/epan/dissectors/packet-bittorrent.c
+++ b/epan/dissectors/packet-bittorrent.c
@@ -166,9 +166,9 @@ static gboolean bittorrent_desegment = TRUE;
static gboolean decode_client_information = FALSE;
struct client_information {
- char id[4];
+ char id[5]; /* string length must be <= 4 to allow space for NUL termination byte */
char ver_len;
- const char *name;
+ const char *name; /* NULL means array entry terminates the array */
};
static struct client_information peer_id[] = {
@@ -759,7 +759,7 @@ static void dissect_bittorrent_welcome (tvbuff_t *tvb, packet_info *pinfo _U_, p
proto_tree_add_item(tree, hf_bittorrent_peer_id, tvb, offset, 20, FALSE);
if(decode_client_information) {
- for(i = 0; peer_id[i].id[0] != '\0'; ++i)
+ for(i = 0; peer_id[i].name != NULL; ++i)
{
if(tvb_memeql(tvb, offset, peer_id[i].id, (int)strlen(peer_id[i].id)) == 0) {
version = tvb_get_ephemeral_string(tvb, offset + (int)strlen(peer_id[i].id),