From 6b61967507eb36819d627e39171439ed21c0e322 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Sat, 16 Dec 2023 11:34:38 +0000 Subject: [PATCH] s3: fix crash if no UploadId in multipart upload Before this change if the S3 API returned a multipart upload with no UploadId then rclone would crash. This detects the problem and attempts to retry the multipart upload creation. See: https://forum.rclone.org/t/panic-runtime-error-invalid-memory-address-or-nil-pointer-dereference/43425 --- backend/s3/s3.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/backend/s3/s3.go b/backend/s3/s3.go index 8f690b38d..f71c44121 100644 --- a/backend/s3/s3.go +++ b/backend/s3/s3.go @@ -5678,6 +5678,13 @@ func (f *Fs) OpenChunkWriter(ctx context.Context, remote string, src fs.ObjectIn var mOut *s3.CreateMultipartUploadOutput err = f.pacer.Call(func() (bool, error) { mOut, err = f.c.CreateMultipartUploadWithContext(ctx, &mReq) + if err == nil { + if mOut == nil { + err = fserrors.RetryErrorf("internal error: no info from multipart upload") + } else if mOut.UploadId == nil { + err = fserrors.RetryErrorf("internal error: no UploadId in multpart upload: %#v", *mOut) + } + } return f.shouldRetry(ctx, err) }) if err != nil {