return false;
}
+ /* Sanity-check the fork number. */
+ if (sentry.forknum < 0 || sentry.forknum > MAX_FORKNUM)
+ {
+ reader->error_callback(reader->error_callback_arg,
+ "file \"%s\" has invalid fork number %d",
+ reader->error_filename, sentry.forknum);
+ return false;
+ }
+
/*
* Sanity-check the nchunks value. In the backend, palloc_array would
* enforce this anyway (with a more generic error message); but in
BlockRefTableRead(reader, reader->chunk_size,
sentry.nchunks * sizeof(uint16));
+ /* Sanity-check the chunk sizes. */
+ for (unsigned i = 0; i < sentry.nchunks; ++i)
+ {
+ if (reader->chunk_size[i] > MAX_ENTRIES_PER_CHUNK)
+ {
+ reader->error_callback(reader->error_callback_arg,
+ "file \"%s\" chunk %u has invalid size %u",
+ reader->error_filename, i,
+ (unsigned) reader->chunk_size[i]);
+ return false;
+ }
+ }
+
/* Set up for chunk scan. */
reader->total_chunks = sentry.nchunks;
reader->consumed_chunks = 0;