From 1a75c71907c6b67914174c8a9fded34c7b1d96d3 Mon Sep 17 00:00:00 2001 From: Shengjing Zhu Date: Sun, 27 Mar 2022 19:38:07 +0800 Subject: [PATCH] Fix panic in inmemory driver Signed-off-by: Shengjing Zhu --- registry/storage/driver/inmemory/mfs.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/registry/storage/driver/inmemory/mfs.go b/registry/storage/driver/inmemory/mfs.go index 8134e1cc..9ac8d434 100644 --- a/registry/storage/driver/inmemory/mfs.go +++ b/registry/storage/driver/inmemory/mfs.go @@ -284,6 +284,9 @@ func (f *file) sectionReader(offset int64) io.Reader { } func (f *file) ReadAt(p []byte, offset int64) (n int, err error) { + if offset >= int64(len(f.data)) { + return 0, io.EOF + } return copy(p, f.data[offset:]), nil }