From 4b83bfd8ac77b31ddff99b8975424dacbe6c38cf Mon Sep 17 00:00:00 2001 From: wmeier Date: Mon, 31 Jan 2011 21:23:35 +0000 Subject: 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 --- epan/dissectors/packet-bittorrent.c | 6 +++--- 1 file 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), -- cgit v1.2.3