diff --git a/storage/aws/aws.go b/storage/aws/aws.go index 08f2ebac..6ad61ba8 100644 --- a/storage/aws/aws.go +++ b/storage/aws/aws.go @@ -629,6 +629,9 @@ func (m *MigrationStorage) fetchLeafHashes(ctx context.Context, from, to, source if err != nil { return fmt.Errorf("bundleHasherFunc for bundle index %d: %v", ri.Index, err) } + if l := len(bh); l < int(ri.First+ri.N) { + return fmt.Errorf("bundle index %d has fewer entries than expected (%d < %d)", ri.Index, l, ri.First+ri.N) + } toBeAdded.Store(ri.Index, bh[ri.First:ri.First+ri.N]) return nil }) diff --git a/storage/gcp/gcp.go b/storage/gcp/gcp.go index 7e74da7b..3a97acd2 100644 --- a/storage/gcp/gcp.go +++ b/storage/gcp/gcp.go @@ -1535,6 +1535,9 @@ func (m *MigrationStorage) fetchLeafHashes(ctx context.Context, from, to, source if err != nil { return fmt.Errorf("bundleHasherFunc for bundle index %d: %v", ri.Index, err) } + if l := len(bh); l < int(ri.First+ri.N) { + return fmt.Errorf("bundle index %d has fewer entries than expected (%d < %d)", ri.Index, l, ri.First+ri.N) + } toBeAdded.Store(ri.Index, bh[ri.First:ri.First+ri.N]) return nil }) diff --git a/storage/posix/files.go b/storage/posix/files.go index e7117083..560c08c0 100644 --- a/storage/posix/files.go +++ b/storage/posix/files.go @@ -1116,6 +1116,9 @@ func (m *MigrationStorage) fetchLeafHashes(ctx context.Context, from, to, source if err != nil { return nil, fmt.Errorf("bundleHasherFunc for bundle index %d: %v", ri.Index, err) } + if l := len(bh); l < int(ri.First+ri.N) { + return nil, fmt.Errorf("bundle index %d has fewer entries than expected (%d < %d)", ri.Index, l, ri.First+ri.N) + } lh = append(lh, bh[ri.First:ri.First+ri.N]...) n++ if n >= maxBundles {