Skip to content

fix(ipc): Don't read past the footer when reporting a bad file magic - #985

Open
pedrobtz wants to merge 1 commit into
apache:mainfrom
pedrobtz:fix-ipc-footer-magic-message
Open

pedrobtz wants to merge 1 commit into
apache:mainfrom
pedrobtz:fix-ipc-footer-magic-message

Conversation

@pedrobtz

Copy link
Copy Markdown

When a file does not end with ARROW1, ArrowIpcDecoderPeekFooter() reports "Expected file to end with ARROW1 but got %s" with data_end, which points one byte past the end of the input. The input is not NUL-terminated, so %s reads past the buffer until it finds a zero byte. The message now prints the six bytes that were compared, with %.6s on magic.

The existing NanoarrowIpcFooterDecodingErrors case passes a string literal, which happens to have a NUL just past its end, so it never showed the over-read. The new case copies the same ten bytes into a heap buffer of exactly that size and checks the message. Without the fix, ASan reports a heap-buffer-overflow there.

Found by fuzzing the IPC reader in the zuarrow R package, which vendors nanoarrow.

ctest passes with ASan and UBSan (409 tests). The changed files are formatted with the pinned clang-format 16.0.6.

🤖 Generated with Claude Code

The error message printed the input as a string starting one byte past
its end. Print the six bytes that were compared instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant