iemejia commented on code in PR #3864:
URL: https://github.com/apache/avro/pull/3864#discussion_r3566979950
##########
lang/perl/lib/Avro/BinaryDecoder.pm:
##########
@@ -296,13 +504,18 @@ sub decode_map {
my $block_count = decode_long($class, @_);
my $writer_values = $writer_schema->values;
my $reader_values = $reader_schema->values;
+ # A map key is a non-empty string (decode_map rejects empty keys below), so
+ # its minimum on-wire size is 2 bytes: a 1-byte length prefix plus at least
+ # 1 byte of key data, in addition to the value.
+ my $min_bytes = 2 + _min_bytes_per_element($writer_values);
while ($block_count) {
my $block_size;
if ($block_count < 0) {
$block_count = -$block_count;
$block_size = decode_long($class, @_);
## XXX we can skip with $reader_schema?
}
+ _ensure_collection_available($reader, scalar(keys %hash),
$block_count, $min_bytes);
for (1..$block_count) {
Review Comment:
Fixed in f2b4562121. decode_map now tracks decoded entries in a separate
`$decoded` counter (incremented by each block's count) and uses it for the
cumulative limit check, instead of `scalar(keys %hash)` which undercounts
duplicate keys.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]