bencode: Fix for truncated packets

Some applications emits improper bencode packets (w/o terminating 'e' -
they erroneously imply that EOF can be considered as a
end-of-dictionary). Let's not fail while parsing these packets.

Change-Id: Ib650e246c7f56b40ef07227eb0dd175a30e4d3a9
Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
This commit is contained in:
Peter Lemenkov 2021-04-01 21:19:51 +02:00
parent bc96d375ab
commit da2cdf7a39
1 changed files with 1 additions and 1 deletions

View File

@ -226,7 +226,7 @@ static int dissect_bencoding_rec(tvbuff_t *tvb, packet_info *pinfo,
length -= op1len + op2len;
}
proto_tree_add_item(dtree, hf_bencode_truncated_data, tvb, offset + used, -1, ENC_NA);
proto_tree_add_item(dtree, hf_bencode_truncated_data, tvb, offset + used, length ? -1 : 0, ENC_NA);
return -1;
case 'l':