ump45nose commented on PR #983:
URL: https://github.com/apache/arrow-nanoarrow/pull/983#issuecomment-6344471917

   Thanks @paleolimbot. 487d8a9 adds `_ArrowInt64FitsInSizeT()` and 
`_ArrowInt64ToSizeT()` to `inline_types.h` (the second one `NANOARROW_DCHECK`s 
that the value is non-negative and fits in `size_t`). The conversions in this 
PR now go through it, so the IPC reader/writer `memcpy`/`fread`/`fwrite` sizes 
are DCHECKs as you suggested.
   
   The places you asked to check for real:
   
   - `ArrowMalloc()`/`ArrowRealloc()` return `NULL` if the size doesn't fit in 
`size_t`, and `ArrowRealloc()` frees `ptr` in that case.
   - `ArrowIpcEncoderWriteContinuationAndSize()` takes an `int64_t` and checks 
`0 <= size <= INT32_MAX`. `ArrowIpcEncoderFinalizeBuffer()` now returns its 
error instead of `NANOARROW_ASSERT_OK`.
   - The legacy-prefix `memmove` in `ArrowIpcArrayStreamReaderNextHeader()` 
returns `EINVAL` with an error message if the header size is out of range.
   
   `ArrowErrorSetString()` keeps a plain cast because it comes before 
`NANOARROW_DCHECK` is defined, and `src_len` is already bounded by 
`sizeof(error->message)` there.
   
   I ran a Debug build (`NANOARROW_DEBUG`) with IPC and device enabled, and all 
422 ctest tests pass. I couldn't do a real 32-bit build here. The failing 
`meson-build` (`-Warray-bounds` in `utils_test.cc`) and `clang-tidy` jobs fail 
the same way on `main`, and `test-python (3.9)` fails because the runner can't 
find Python 3.9 on Ubuntu 26.04. (AI-assisted reply.)
   


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