Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

s3: fix crash if a bad listing is received - fixes #1927

Nick Craig-Wood255d3e925da2
diff --git a/s3/s3.go b/s3/s3.go
index 359c7ef8e..4d88752f6 100644
--- a/s3/s3.go
+++ b/s3/s3.go
@@ -554,6 +554,9 @@ func (f *Fs) list(dir string, recurse bool, fn listFn) error {
}
// Use NextMarker if set, otherwise use last Key
if resp.NextMarker == nil || *resp.NextMarker == "" {
+ if len(resp.Contents) == 0 {
+ return errors.New("s3 protocol error: received listing with IsTruncated set, no NextMarker and no Contents")
+ }
marker = resp.Contents[len(resp.Contents)-1].Key
} else {
marker = resp.NextMarker