Skip to content

ArrowIpcDecoderDecodeFooter() crashes on a footer with no schema instead of returning EINVAL #1022

Closed

Description

@shashank11yadav

Describe the bug

ArrowIpcDecoderDecodeFooter() passes Footer_schema(footer) to the schema decoders without checking it for NULL. For a well-formed footer flatbuffer that has no schema field, the call aborts on flatcc's "null pointer table access" assert (or dereferences NULL when built with NDEBUG) instead of returning an error. ArrowIpcDecoderVerifyFooter() rejects the same input ("Footer has no schema"), so only callers that decode without verifying first are affected.

To reproduce

#define _POSIX_C_SOURCE 200809L
#include <stdio.h>
#include <string.h>
#include <sys/wait.h>
#include <unistd.h>

#include "nanoarrow/nanoarrow.h"
#include "nanoarrow/nanoarrow_ipc.h"

int main(void) {
  // Footer flatbuffer: root offset 8; vtable (size 4, table size 4); empty table.
  // No schema, no record batches. Then int32 footer size (12) and "ARROW1".
  static const uint8_t buf[] = {8, 0, 0, 0, 4,  0,   4,   0,   4,   0,   0,
                                0, 12, 0, 0, 0, 'A', 'R', 'R', 'O', 'W', '1'};
  struct ArrowBufferView data;
  data.data.as_uint8 = buf;
  data.size_bytes = sizeof(buf);

  printf("EXPECTED: DecodeFooter returns an error code (EINVAL) for a footer with no schema\n");
  fflush(stdout);
  fflush(stderr);

  pid_t pid = fork();
  if (pid < 0) return 2;
  if (pid == 0) {
    struct ArrowIpcDecoder decoder;
    struct ArrowError error;
    error.message[0] = '\0';
    if (ArrowIpcDecoderInit(&decoder) != NANOARROW_OK) _exit(2);
    if (ArrowIpcDecoderPeekFooter(&decoder, data, &error) != NANOARROW_OK) _exit(2);
    int rc = ArrowIpcDecoderDecodeFooter(&decoder, data, &error);
    _exit(rc == NANOARROW_OK ? 3 : 0);
  }

  int status = 0;
  if (waitpid(pid, &status, 0) < 0) return 2;
  if (WIFSIGNALED(status)) {
    printf("ACTUAL: DecodeFooter crashed (signal %d)\n", WTERMSIG(status));
    return 1;
  }
  int code = WEXITSTATUS(status);
  if (code == 3) {
    printf("ACTUAL: DecodeFooter returned NANOARROW_OK\n");
    return 1;
  }
  printf("ACTUAL: DecodeFooter returned an error code (child exit %d)\n", code);
  return 0;
}

Output on main (1292ac0):

EXPECTED: DecodeFooter returns an error code (EINVAL) for a footer with no schema
ACTUAL: DecodeFooter crashed (signal 6)

The crash is flatcc's assert in flatcc_generated.h (org_apache_arrow_flatbuf_Schema_endianness: Assertion 't__tmp != 0 && "null pointer table access"' failed), printed to stderr just before the ACTUAL line. The 0.9.0 tag gives the same output.

Expected behavior

nanoarrow_ipc.h says ArrowIpcDecoderDecodeFooter() "Returns EINVAL if the content of the footer cannot be decoded". The header-side twin already does this: #960 added a NULL message-header check to ArrowIpcDecoderDecodeHeader(), which has the same "In almost all cases this should be preceded by" a verify call wording.

Versions

  • nanoarrow 0.9.0 and main @ 1292ac0 (both affected)
  • gcc 15.2.0, Linux aarch64; CMake Debug build with -DNANOARROW_IPC=ON; repro built with -std=c11 -g -fsanitize=address,undefined

Additional context

Root cause: src/nanoarrow/ipc/decoder.c:1982-1985, Footer_schema(footer) goes straight into ArrowIpcDecoderDecodeSchemaHeader / ArrowIpcDecoderDecodeSchemaImpl. A NULL check after Footer_as_root that sets "Footer has no schema" and returns EINVAL (the same message ArrowIpcDecoderVerifyFooter() uses) would fix it. The API is marked as public only for integration testing.

I have a fix with a regression test ready and will open a pull request for it right after filing this issue; it will link back here.

Activity

  1. added a commit that references this issue on Nov 18, 2026
    b7a56da
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions