"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files
Go azure-blobazure-blob-storageazure-filesbackblaze-b2cloud-storagedropboxencryptionftpfuse-filesystemgogolanggoogle-cloud-storagegoogle-driveonedriveopenstack-swiftrclones3sftpsyncwebdav
copy: fix nil pointer dereference when corrupted on transfer with nil dst
nielashe053c8a1c03e
diff --git a/backend/local/local_internal_test.go b/backend/local/local_internal_test.goindex 06e47bed2..68ca696a6 100644--- a/backend/local/local_internal_test.go+++ b/backend/local/local_internal_test.go@@ -76,6 +76,23 @@ func TestUpdatingCheck(t *testing.T) {}+// Test corrupted on transfer+// should error due to size/hash mismatch+func TestVerifyCopy(t *testing.T) {+ r := fstest.NewRun(t)+ filePath := "sub dir/local test"+ r.WriteFile(filePath, "some content", time.Now())+ src, err := r.Flocal.NewObject(context.Background(), filePath)+ require.NoError(t, err)+ src.(*Object).fs.opt.NoCheckUpdated = true++ for i := 0; i < 100; i++ {+ go r.WriteFile(src.Remote(), fmt.Sprintf("some new content %d", i), src.ModTime(context.Background()))+ }+ _, err = operations.Copy(context.Background(), r.Fremote, nil, filePath+"2", src)+ assert.Error(t, err)+}+func TestSymlink(t *testing.T) {ctx := context.Background()r := fstest.NewRun(t)diff --git a/fs/operations/copy.go b/fs/operations/copy.goindex 45fb3f64a..41605e901 100644--- a/fs/operations/copy.go+++ b/fs/operations/copy.go@@ -266,14 +266,14 @@ func (c *copy) manualCopy(ctx context.Context) (actionTaken string, newDst fs.Obfunc (c *copy) verify(ctx context.Context, newDst fs.Object) (err error) {// Verify sizes are the same after transferif sizeDiffers(ctx, c.src, newDst) {- return fmt.Errorf("corrupted on transfer: sizes differ src(%s) %d vs dst(%s) %d", c.src.Fs(), c.src.Size(), c.dst.Fs(), c.dst.Size())+ return fmt.Errorf("corrupted on transfer: sizes differ src(%s) %d vs dst(%s) %d", c.src.Fs(), c.src.Size(), newDst.Fs(), newDst.Size())}// Verify hashes are the same after transfer - ignoring blank hashesif c.hashType != hash.None {// checkHashes has logs and counts errorsequal, _, srcSum, dstSum, _ := checkHashes(ctx, c.src, newDst, c.hashType)if !equal {- return fmt.Errorf("corrupted on transfer: %v hashes differ src(%s) %q vs dst(%s) %q", c.hashType, c.src.Fs(), srcSum, c.dst.Fs(), dstSum)+ return fmt.Errorf("corrupted on transfer: %v hashes differ src(%s) %q vs dst(%s) %q", c.hashType, c.src.Fs(), srcSum, newDst.Fs(), dstSum)}}return nil