iemejia commented on code in PR #3860:
URL: https://github.com/apache/avro/pull/3860#discussion_r3565239771


##########
lang/csharp/src/apache/main/IO/BinaryDecoder.cs:
##########
@@ -264,11 +264,53 @@ public void SkipFixed(int len)
         // Read p bytes into a new byte buffer
         private byte[] read(long p)
         {
+            if (p < 0)
+            {
+                throw new AvroException($"Can not read a negative number of 
bytes: {p}");
+            }
+
+            EnsureAvailableBytes(p);
             byte[] buffer = new byte[p];
             Read(buffer, 0, buffer.Length);

Review Comment:
   Fixed in 4232c99: read(long) now rejects a length above MaxDotNetArrayLength 
(per TFM) with a consistent AvroException before allocating, matching 
ReadString(). Added a test that uses a non-seekable stream so the check is 
reached without gigabytes of data.



-- 
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]

Reply via email to