diff options
author | Bill Meier <wmeier@newsguy.com> | 2011-01-31 21:23:35 +0000 |
---|---|---|
committer | Bill Meier <wmeier@newsguy.com> | 2011-01-31 21:23:35 +0000 |
commit | af30978c394de37066418bb628867ab01b6726bc (patch) | |
tree | 7b424da6c5f12257eb3aca5fc16470bef98e71aa | |
parent | c8e6818a239afcd254eb2284f57853cb6fc9f8ee (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"
svn path=/trunk/; revision=35732
-rw-r--r-- | epan/dissectors/packet-bittorrent.c | 6 |
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), |