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

Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
Steve Weis 2026-03-20 14:02:09 -07:00 committed by GitHub
parent db09cd66d1
commit 4c86929a84
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -76,6 +76,7 @@ func (w *WrappedBase64Encoder) writeWrapped(p []byte) (int, error) {
if w.buf.Len() != 0 {
panic("age: internal error: non-empty WrappedBase64Encoder.buf")
}
total := len(p)
for len(p) > 0 {
toWrite := min(ColumnsPerLine-(w.written%ColumnsPerLine), len(p))
n, _ := w.buf.Write(p[:toWrite])
@ -91,7 +92,7 @@ func (w *WrappedBase64Encoder) writeWrapped(p []byte) (int, error) {
// are not recoverable anyway.
return 0, err
}
return len(p), nil
return total, nil
}
// LastLineIsEmpty returns whether the last output line was empty, either