From 16ad749c854ed1ccb5d9858130f37e0738565390 Mon Sep 17 00:00:00 2001 From: NickEdwards7502 Date: Mon, 18 May 2026 12:44:09 +1000 Subject: [PATCH] Fix s3_seek to return the actual seek position. When the seek target falls within the already-cached S3 chunk, s3_seek updates last_read_buffer but does not update last_read. Returning fp->last_read in this case gives the end of the chunk rather than the seek target, causing hseek() to set fp->offset incorrectly. Fix by returning pos directly in both the cache-hit and cache-miss branches. Assisted-by: GitHub-Copilot:claude-sonnet-4.6 Signed-off-by: Nick Edwards --- hfile_s3.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hfile_s3.c b/hfile_s3.c index 30de86e27..a766b4da8 100644 --- a/hfile_s3.c +++ b/hfile_s3.c @@ -2063,7 +2063,7 @@ static off_t s3_seek(hFILE *fpv, off_t offset, int whence) { ks_clear(&fp->buffer); // resetting fp->buffer triggers a new remote read } - return fp->last_read; + return (off_t) pos; }