summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2023-07-22 00:56:38 -0600
committerLuke Shumaker <lukeshu@lukeshu.com>2023-07-22 00:56:38 -0600
commit8b2af4e0ec1ed6d07ce5f9da5a5e3cdfa010522d (patch)
treea92675c6a331ff56cd6640556ea3425da5834879
parent7a1389d3a92955db0ef1e4b5fd9f55cd7906a693 (diff)
rebuildmappings scan: Fix a use-after-free bug
-rw-r--r--cmd/btrfs-rec/inspect/rebuildmappings/scan.go8
1 files changed, 4 insertions, 4 deletions
diff --git a/cmd/btrfs-rec/inspect/rebuildmappings/scan.go b/cmd/btrfs-rec/inspect/rebuildmappings/scan.go
index 76d8a75..d96005e 100644
--- a/cmd/btrfs-rec/inspect/rebuildmappings/scan.go
+++ b/cmd/btrfs-rec/inspect/rebuildmappings/scan.go
@@ -133,7 +133,7 @@ func (scanner *deviceScanner) ScanNode(ctx context.Context, addr btrfsvol.Physic
addr, i)
scanner.result.FoundChunks = append(scanner.result.FoundChunks, FoundChunk{
Key: item.Key,
- Chunk: *itemBody,
+ Chunk: itemBody.Clone(),
})
case *btrfsitem.Error:
dlog.Errorf(ctx, "node@%v: item %v: error: malformed CHUNK_ITEM: %v",
@@ -148,7 +148,7 @@ func (scanner *deviceScanner) ScanNode(ctx context.Context, addr btrfsvol.Physic
addr, i)
scanner.result.FoundBlockGroups = append(scanner.result.FoundBlockGroups, FoundBlockGroup{
Key: item.Key,
- BG: *itemBody,
+ BG: itemBody.Clone(),
})
case *btrfsitem.Error:
dlog.Errorf(ctx, "node@%v: item %v: error: malformed BLOCK_GROUP_ITEM: %v",
@@ -163,7 +163,7 @@ func (scanner *deviceScanner) ScanNode(ctx context.Context, addr btrfsvol.Physic
addr, i)
scanner.result.FoundDevExtents = append(scanner.result.FoundDevExtents, FoundDevExtent{
Key: item.Key,
- DevExt: *itemBody,
+ DevExt: itemBody.Clone(),
})
case *btrfsitem.Error:
dlog.Errorf(ctx, "node@%v: item %v: error: malformed DEV_EXTENT: %v",
@@ -178,7 +178,7 @@ func (scanner *deviceScanner) ScanNode(ctx context.Context, addr btrfsvol.Physic
addr, i)
scanner.result.FoundExtentCSums = append(scanner.result.FoundExtentCSums, FoundExtentCSum{
Generation: node.Head.Generation,
- Sums: *itemBody,
+ Sums: itemBody.Clone(),
})
case *btrfsitem.Error:
dlog.Errorf(ctx, "node@%v: item %v: error: malformed is EXTENT_CSUM: %v",