This is an automated email from the ASF dual-hosted git repository. xuanwo pushed a commit to branch fix-fuzz-failure-2717 in repository https://gitbox.apache.org/repos/asf/incubator-opendal.git
commit 8d0ca89a9cc1961933196dbcfa162692d646937f Author: Xuanwo <[email protected]> AuthorDate: Wed Jul 26 18:09:27 2023 +0800 fix: Seek before the start of file should be invalid Signed-off-by: Xuanwo <[email protected]> --- core/src/raw/oio/read/into_read_from_file.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/core/src/raw/oio/read/into_read_from_file.rs b/core/src/raw/oio/read/into_read_from_file.rs index 52ebbfec2..05bbff2df 100644 --- a/core/src/raw/oio/read/into_read_from_file.rs +++ b/core/src/raw/oio/read/into_read_from_file.rs @@ -89,10 +89,16 @@ where }; match base.checked_add(offset) { + // Seek to position like `-123` is invalid. Some(n) if n < 0 => Poll::Ready(Err(Error::new( ErrorKind::InvalidInput, - "invalid seek to a negative or overflowing position", - ))), + "seek to a negative or overflowing position is invalid", + ).with_context("position", n.to_string()))), + // Seek to position before the start of current file is invalid. + Some(n) if n < self.start as i64 => Poll::Ready(Err(Error::new( + ErrorKind::InvalidInput, + "seek to a position before start of file is invalid", + ).with_context("position", n.to_string()).with_context("start", self.start.to_string()))), Some(n) => { let cur = ready!(Pin::new(&mut self.inner).poll_seek(cx, SeekFrom::Start(n as u64)))
