From 4c86929a84aac61aaca81ec67d7ccce9d1fad727 Mon Sep 17 00:00:00 2001 From: Steve Weis Date: Fri, 20 Mar 2026 14:02:09 -0700 Subject: [PATCH] internal/format: return correct byte count from writeWrapped (#698) Co-authored-by: Claude --- internal/format/format.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/internal/format/format.go b/internal/format/format.go index cc788c3..794b48a 100644 --- a/internal/format/format.go +++ b/internal/format/format.go @@ -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