From 061c8752bbba03c9d94ff0f02d734ea86cf5f673 Mon Sep 17 00:00:00 2001 From: "Mads R. B. Kristensen" Date: Wed, 23 Mar 2022 09:03:58 +0100 Subject: [PATCH] Adding "Offset is past end of file" checks --- cpp/src/io/utilities/datasource.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cpp/src/io/utilities/datasource.cpp b/cpp/src/io/utilities/datasource.cpp index 3e5f2666b29..6743ada8790 100644 --- a/cpp/src/io/utilities/datasource.cpp +++ b/cpp/src/io/utilities/datasource.cpp @@ -156,6 +156,7 @@ class direct_read_source : public file_source { std::unique_ptr host_read(size_t offset, size_t size) override { + CUDF_EXPECTS(offset < _file.nbytes(), "Offset is past end of file"); lseek(_file.fd(), offset, SEEK_SET); // Clamp length to available data @@ -168,6 +169,7 @@ class direct_read_source : public file_source { size_t host_read(size_t offset, size_t size, uint8_t* dst) override { + CUDF_EXPECTS(offset < _file.nbytes(), "Offset is past end of file"); lseek(_file.fd(), offset, SEEK_SET); // Clamp length to available data