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


##########
lang/csharp/src/apache/main/File/DataFileReader.cs:
##########
@@ -233,7 +233,7 @@ public string GetMetaString(string key)
             catch (Exception e)
             {
                 throw new 
AvroRuntimeException(string.Format(CultureInfo.InvariantCulture,
-                    "Error fetching meta data for key: {0}", key), e);
+                    "Error fetching next object from block: {0}", e.Message), 
e);
             }

Review Comment:
   Fixed. My earlier change had accidentally edited GetMetaString's catch. 
Restored its metadata-specific message ("Error fetching meta data for key: 
{key}") with the inner exception preserved. Pushed in 7a05ac1.



##########
lang/csharp/src/apache/main/File/DataFileReader.cs:
##########
@@ -335,6 +335,11 @@ public bool HasNext()
                     {
                         _currentBlock = NextRawBlock(_currentBlock);
                         _currentBlock.Data = 
_codec.Decompress(_currentBlock.Data, (int)_blockSize);
+                        // Guard against a block that decompresses to more 
than the
+                        // allowed maximum (a decompression bomb). The 
built-in deflate
+                        // codec is already bounded during decompression; this 
covers
+                        // any codec that returns a fully decompressed buffer.
+                        Codec.CheckDecompressLength(_currentBlock.Data.Length, 
Codec.GetMaxDecompressLength());

Review Comment:
   Fixed. The inner-exception preservation is now applied to HasNext() (the 
intended target): it passes the original exception as InnerException and uses 
e.Message in the wrapper text. Pushed in 7a05ac1.



##########
lang/csharp/src/apache/main/File/DataFileReader.cs:
##########
@@ -335,6 +335,11 @@ public bool HasNext()
                     {
                         _currentBlock = NextRawBlock(_currentBlock);
                         _currentBlock.Data = 
_codec.Decompress(_currentBlock.Data, (int)_blockSize);
+                        // Guard against a block that decompresses to more 
than the
+                        // allowed maximum (a decompression bomb). The 
built-in deflate
+                        // codec is already bounded during decompression; this 
covers
+                        // any codec that returns a fully decompressed buffer.
+                        Codec.CheckDecompressLength(_currentBlock.Data.Length, 
Codec.GetMaxDecompressLength());

Review Comment:
   Fixed. Added TestReaderRejectsOversizedBlock, which writes a Null-codec 
block larger than the limit and asserts the DataFileReader read path (HasNext 
-> CheckDecompressLength) rejects it, covering codecs that return a fully 
materialized buffer. Pushed in 7a05ac1.



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