iemejia commented on code in PR #3860:
URL: https://github.com/apache/avro/pull/3860#discussion_r3567401034
##########
lang/csharp/src/apache/main/IO/BinaryDecoder.cs:
##########
@@ -76,6 +76,13 @@ public long ReadLong()
int shift = 7;
while ((b & 0x80) != 0)
{
+ // A 64-bit value uses at most 10 bytes (shifts 0..63); reject
an
+ // overlong varint rather than silently wrapping to a wrong
value.
+ if (shift >= 70)
+ {
+ throw new AvroException("Varint is too long");
+ }
+
b = read();
n |= (b & 0x7FUL) << shift;
shift += 7;
Review Comment:
Fixed — when `shift == 63` (the 10th byte) ReadLong now rejects the input if
`(b & 0x7E) != 0`, since those higher payload bits would be dropped by `<< 63`
and silently decode a malformed varint to a wrong value.
--
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]