iemejia commented on code in PR #3860:
URL: https://github.com/apache/avro/pull/3860#discussion_r3567503802
##########
lang/csharp/src/apache/main/Generic/GenericReader.cs:
##########
@@ -404,11 +404,52 @@ protected virtual object ReadArray(object reuse,
ArraySchema writerSchema, Schem
ArraySchema rs = (ArraySchema)readerSchema;
object result = CreateArray(reuse, rs);
int i = 0;
- for (int n = (int)d.ReadArrayStart(); n != 0; n =
(int)d.ReadArrayNext())
+ long minBytes = MinBytesPerElement(writerSchema.ItemSchema);
+ long total = 0;
+ for (long nl = d.ReadArrayStart(); nl != 0; nl = d.ReadArrayNext())
{
- if (GetArraySize(result) < (i + n)) ResizeArray(ref result, i
+ n);
+ // Reject a block whose element count could not be backed by
the
Review Comment:
Good catch — this is a real gap specific to C#'s architecture:
`PreresolvingDatumReader<T>` (base of
SpecificDatumReader<T>/GenericDatumReader<T>) is a separate reader
implementation from the DefaultReader/GenericReader path hardened in this PR,
so it doesn't inherit these checks (unlike Java, where SpecificDatumReader
extends the hardened GenericDatumReader). Hardening it means sharing the limit
logic, threading element min-bytes into ReadArray/ReadMap, clamping EnsureSize
preallocation, and adding tests on the specific-reader path — a distinct change
with its own regression risk on a widely-used path. Filed as AVRO-4306
(https://issues.apache.org/jira/browse/AVRO-4306) to do it properly with
dedicated tests rather than bolt it onto this PR late in review.
--
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]