Skip to content

internal/format: return correct byte count from writeWrapped#698

Open
sweis wants to merge 1 commit intoFiloSottile:mainfrom
sweis:claude/fix-wrapped-base64-return-HXoHp
Open

internal/format: return correct byte count from writeWrapped#698
sweis wants to merge 1 commit intoFiloSottile:mainfrom
sweis:claude/fix-wrapped-base64-return-HXoHp

Conversation

@sweis
Copy link

@sweis sweis commented Mar 12, 2026

writeWrapped slices its argument p down to zero in a loop, then returns
len(p) — always (0, nil) on success. This violates the io.Writer contract.
Harmless today because encoding/base64 ignores the count, but
WrappedBase64Encoder / WriterFunc are exported.

Fix: save the original length before the loop.

Test: go test ./internal/format/ -run TestWriteWrappedReturnsCorrectLength -v

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.

2 participants