From 8619a11f73b92b9f5307a7b3c040f09dfbed6f61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Otto=20Kr=C3=B6pke?= Date: Fri, 19 Jul 2024 15:12:54 +0200 Subject: [PATCH] fix nil pointer in s3 list api MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jan-Otto Kröpke --- registry/storage/driver/s3-aws/s3.go | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/registry/storage/driver/s3-aws/s3.go b/registry/storage/driver/s3-aws/s3.go index be74c51c7..48db5f4a1 100644 --- a/registry/storage/driver/s3-aws/s3.go +++ b/registry/storage/driver/s3-aws/s3.go @@ -874,20 +874,20 @@ func (d *driver) List(ctx context.Context, opath string) ([]string, error) { directories = append(directories, strings.Replace(commonPrefix[0:len(commonPrefix)-1], d.s3Path(""), prefix, 1)) } - if *resp.IsTruncated { - resp, err = d.S3.ListObjectsV2WithContext(ctx, &s3.ListObjectsV2Input{ - Bucket: aws.String(d.Bucket), - Prefix: aws.String(d.s3Path(path)), - Delimiter: aws.String("/"), - MaxKeys: aws.Int64(listMax), - ContinuationToken: resp.NextContinuationToken, - }) - if err != nil { - return nil, err - } - } else { + if resp.IsTruncated == nil || !*resp.IsTruncated { break } + + resp, err = d.S3.ListObjectsV2WithContext(ctx, &s3.ListObjectsV2Input{ + Bucket: aws.String(d.Bucket), + Prefix: aws.String(d.s3Path(path)), + Delimiter: aws.String("/"), + MaxKeys: aws.Int64(listMax), + ContinuationToken: resp.NextContinuationToken, + }) + if err != nil { + return nil, err + } } if opath != "/" {