From 255d3e925da2474445d0ab37ec4ab54bb7c46105 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Wed, 20 Dec 2017 16:40:41 +0000 Subject: [PATCH] s3: fix crash if a bad listing is received - fixes #1927 Caringo Swarm is returning a listing with IsTruncated set but no NextMarker and no Keys. Rclone doesn't know how to continue the listing at this point, so it returns an error rather than truncating the listing or risking a loop. --- s3/s3.go | 3 +++ 1 file changed, 3 insertions(+) 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