diff options
author | John Thacker <johnthacker@gmail.com> | 2022-12-01 20:38:35 -0500 |
---|---|---|
committer | John Thacker <johnthacker@gmail.com> | 2022-12-01 20:43:39 -0500 |
commit | 0e119321837e6ec69fe6cb04aee04935e0386d7a (patch) | |
tree | 6ef7ee7ccb72f6fca765aa55e28d7c07638765e2 | |
parent | 967a3c3df94d09a09306a23ae248ef611f57087b (diff) |
kafka: Don't try to decompress if the length is zero.
There's no point in trying to decompress a message with
length zero, and some of the third party decompression
libraries (e.g. zstd) can give unexpected results that
lead to infinite loops if we do so. A message length zero
is almost surely a file with errors.
-rw-r--r-- | epan/dissectors/packet-kafka.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/epan/dissectors/packet-kafka.c b/epan/dissectors/packet-kafka.c index f60ecda88c..aaef2d36c5 100644 --- a/epan/dissectors/packet-kafka.c +++ b/epan/dissectors/packet-kafka.c @@ -267,6 +267,7 @@ static expert_field ei_kafka_bad_record_length = EI_INIT; static expert_field ei_kafka_bad_varint = EI_INIT; static expert_field ei_kafka_bad_message_set_length = EI_INIT; static expert_field ei_kafka_bad_decompression_length = EI_INIT; +static expert_field ei_kafka_zero_decompression_length = EI_INIT; static expert_field ei_kafka_unknown_message_magic = EI_INIT; static expert_field ei_kafka_pdu_length_mismatch = EI_INIT; @@ -1874,6 +1875,10 @@ decompress(tvbuff_t *tvb, packet_info *pinfo, int offset, guint32 length, int co expert_add_info(pinfo, NULL, &ei_kafka_bad_decompression_length); return FALSE; } + if (length == 0) { + expert_add_info(pinfo, NULL, &ei_kafka_zero_decompression_length); + return FALSE; + } switch (codec) { case KAFKA_MESSAGE_CODEC_SNAPPY: return decompress_snappy(tvb, pinfo, offset, length, decompressed_tvb, decompressed_offset); @@ -10246,6 +10251,8 @@ proto_register_kafka_expert_module(const int proto) { { "kafka.ei_kafka_bad_message_set_length", PI_MALFORMED, PI_WARN, "Message set size does not match content", EXPFILL }}, { &ei_kafka_bad_decompression_length, { "kafka.ei_kafka_bad_decompression_length", PI_MALFORMED, PI_WARN, "Decompression size too large", EXPFILL }}, + { &ei_kafka_zero_decompression_length, + { "kafka.ei_kafka_zero_decompression_length", PI_PROTOCOL, PI_NOTE, "Decompression size zero", EXPFILL }}, { &ei_kafka_unknown_message_magic, { "kafka.unknown_message_magic", PI_MALFORMED, PI_WARN, "Invalid message magic field", EXPFILL }}, { &ei_kafka_pdu_length_mismatch, |