Skip to content

[POSIX] Fix incorrect mirror partial tile reconstruction - #1180

Merged
AlCutter merged 3 commits into
transparency-dev:mainfrom
AlCutter:another_slice_of_tile_vicar
Sep 16, 2026
Merged

AlCutter merged 3 commits into
transparency-dev:mainfrom
AlCutter:another_slice_of_tile_vicar

Conversation

@AlCutter

Copy link
Copy Markdown
Collaborator

This PR addresses an issue with the mirror writer lifecycle implementation in the POSIX driver where it would create an invalid out-of-bounds tile under certain circumstances.

Fixes #1178

@AlCutter
AlCutter requested a review from roger2hk September 16, 2026 11:10
@AlCutter
AlCutter requested a review from a team as a code owner September 16, 2026 11:10
Comment thread storage/posix/files.go
Comment on lines 1400 to 1401
treeP := layout.PartialTileSize(l, idx, treeSize)
cpP := layout.PartialTileSize(l, idx, cpSize)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if you short-circuit earlier here?

Suggested change
cpP := layout.PartialTileSize(l, idx, cpSize)
if cpP == 0 {
continue
}
treeP := layout.PartialTileSize(l, idx, treeSize)

Comment thread storage/posix/files_test.go Outdated
} else {
tile := mustReadTile(t, lr, uint64(level), idx, uint8(wantNodes))
if len(tile.Nodes) != wantNodes {
t.Errorf("Expected %d nodes in partial tile %d/%d.%d, got %d", wantNodes, level, idx, wantNodes, len(tile.Nodes))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the warning message use uint8(wantNodes) instead of wantNodes in case it's the full tile? Otherwise, it may show .256.

Comment thread storage/posix/files.go
Comment on lines 1385 to 1389
// ensureGeometry checks that the partial tiles and entry bundles implied by the new size are
// present in the stored resources.
//
// If an implied partial resource is not already present, this function will attempt to create
// it from a strictly larger resource whose presence is implied by treeSize.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add one more line to the code comment to include the new change?

"When cpSize == treeSize the resources are guaranteed present by integration, so there's nothing to do."

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that's implied on the method comment, but I've added it as an in-line comment on the condition check.

Comment thread storage/posix/files_test.go Outdated

return func(yield func(*api.EntryBundle, error) bool) {
remaining := totalEntries
dummyEntry := []byte("a")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Using []byte("a") doesn't try to catch whether there is any offset. Consider using something like fmt.Appendf(nil, "entry %d", base+i)?

@AlCutter
AlCutter merged commit a820582 into transparency-dev:main Sep 16, 2026
20 checks passed
@AlCutter
AlCutter deleted the another_slice_of_tile_vicar branch September 16, 2026 14:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[POSIX] MirrorWriter publishes truncated tiles/bundles to full-tile/bundle paths

2 participants