Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/nanoarrow/ipc/decoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -1701,7 +1701,8 @@ ArrowErrorCode ArrowIpcDecoderPeekFooter(struct ArrowIpcDecoder* decoder,
const char* footer_size_data = magic - sizeof(int32_t);

if (memcmp(magic, NANOARROW_IPC_MAGIC, strlen(NANOARROW_IPC_MAGIC)) != 0) {
ArrowErrorSet(error, "Expected file to end with ARROW1 but got %s", data_end);
// data is not NUL-terminated: print only the bytes that were compared
ArrowErrorSet(error, "Expected file to end with ARROW1 but got %.6s", magic);
Comment on lines +1704 to +1705

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Realistically this should print out a few hex bytes...there's a very good chance these are non printable characters that will get rendered here

return EINVAL;
}

Expand Down
8 changes: 8 additions & 0 deletions src/nanoarrow/ipc/decoder_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
// under the License.

#include <cstring>
#include <memory>
#include <thread>

#if defined(NANOARROW_BUILD_TESTS_WITH_ARROW)
Expand Down Expand Up @@ -1312,6 +1313,13 @@ TEST(NanoarrowIpcTest, NanoarrowIpcFooterDecodingErrors) {
EINVAL)
<< error.message;

// the message must not read past the end of data, which isn't NUL-terminated
std::unique_ptr<char[]> unterminated(new char[10]);
memcpy(unterminated.get(), "\0\0\0\0blargh", 10);
EXPECT_EQ(ArrowIpcDecoderPeekFooter(decoder.get(), {{unterminated.get()}, 10}, &error),
EINVAL);
EXPECT_STREQ(error.message, "Expected file to end with ARROW1 but got blargh");

// negative size
EXPECT_EQ(ArrowIpcDecoderPeekFooter(decoder.get(),
{{"\xFF\xFF\xFF\xFF"
Expand Down
Loading