shashank11yadav opened a new pull request, #1014:
URL: https://github.com/apache/arrow-nanoarrow/pull/1014

   Fixes #1013
   
   The footer size check in ArrowIpcDecoderVerifyFooter() and 
ArrowIpcDecoderDecodeFooter() adds the header size, sizeof(int32_t) and the 
magic length in size_t and stores the result in an int32_t. 
ArrowIpcDecoderPeekFooter() only rejects negative footer sizes, so a footer 
size near INT32_MAX (for example 0x7FFFFFFE) makes the sum wrap to a negative 
value. The ESPIPE check then passes, and the footer pointer ends up about 2 GiB 
past the end of the buffer, which VerifyFooter and DecodeFooter then read.
   
   This change:
   - Computes the sum as int64_t in both functions, and prints it with PRId64 
in the VerifyFooter message.
   - Adds to ArrowIpcDecoderDecodeFooter() the same ESPIPE check that 
VerifyFooter() has, before the footer pointer is computed. DecodeFooter() had 
no size check, so it now returns ESPIPE for short input instead of reading past 
the buffer.
   
   The approach matches the message header fix in #984 and the check in 
ArrowIpcDecoderDecodeHeader().
   
   Testing:
   - New test NanoarrowIpcTest.NanoarrowIpcFooterSizeOverflow 
(src/nanoarrow/ipc/decoder_test.cc): a 16-byte buffer with footer size 
0x7FFFFFFE. It checks that VerifyFooter() returns ESPIPE with the expected 
message, and that DecodeFooter() returns ESPIPE after PeekFooter().
   - Ran with the CMake build: nanoarrow_ipc_decoder_test passes. The new test 
passes with the fix and fails without it.
   
   - clang-format 16.0.6 (--dry-run --Werror) and codespell 2.2.5 on the 
changed files: clean.
   
   Not run: the full ctest suite, `pre-commit run --all-files`, and the Meson 
CI job.
   


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