From 488791a5a1498caf7cdf1a2b3390398635cf1025 Mon Sep 17 00:00:00 2001 From: Tonis Tiigi Date: Fri, 10 Feb 2023 19:23:39 -0800 Subject: [PATCH] gha: avoid range requests with too big offset Signed-off-by: Tonis Tiigi --- cache/remotecache/gha/gha.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cache/remotecache/gha/gha.go b/cache/remotecache/gha/gha.go index 131076693f81..9b16e7fc9de8 100644 --- a/cache/remotecache/gha/gha.go +++ b/cache/remotecache/gha/gha.go @@ -5,6 +5,7 @@ import ( "context" "encoding/json" "fmt" + "io" "os" "sync" "time" @@ -371,6 +372,13 @@ type readerAt struct { desc ocispecs.Descriptor } +func (r *readerAt) ReadAt(p []byte, off int64) (int, error) { + if off >= r.desc.Size { + return 0, io.EOF + } + return r.ReaderAtCloser.ReadAt(p, off) +} + func (r *readerAt) Size() int64 { return r.desc.Size }