Skip to content

Conversation

@dolmen
Copy link
Contributor

@dolmen dolmen commented Feb 28, 2025

The count of bytes written is incorrectly reported by Base64LineBreaker.Write. This issue is not visible externally as Base64LineBreaker.Write is only called via encoding/base64.Encoder.Write (like in the original implementation in stdlib encoding/pem.lineBreaker) which ignores the returned bytes count.

The issue is not visible either with the test suite (not even via the current fuzzing tests) because the tests also use Base64LineBreaker through the encoding/base64.Encoder.

So we could just keep the existing code. The only risk is if encoding/base64 behavior changes in the future.

See also CL 653675 which aims to fix the same issue in encoding/pem.

The count of bytes written is incorrectly reported by
Base64LineBreaker.Write. This issue is not visible externally as
Base64LineBreaker.Write is only called by encoding/base64.Encoder.Write
(like in the original implementation in stdlib encoding/pem.lineBreaker)
which ignores the returned bytes count.

The issue is not visible either with the test suite (not even via
fuzzing) because the tests use Base64LineBreaker through the
encoding/base64.Encoder.

So we could just keep the existing code. The only risk is if
encoding/base64 behaviour changes in the future.

See also https://go.dev/cl/653675 which aims to fix the same issue in
encoding/pem.
@dolmen
Copy link
Contributor Author

dolmen commented Feb 28, 2025

This fix doesn't extend fuzzing with tests that would target Base64LineBreaker directly because I think it is more important to first remove Base64LineBreaker from the API. See #444.

@codecov
Copy link

codecov bot commented Mar 21, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.35%. Comparing base (3978049) to head (80ef8fe).
Report is 17 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #445      +/-   ##
==========================================
- Coverage   94.34%   93.35%   -0.99%     
==========================================
  Files          30       30              
  Lines        3534     3537       +3     
==========================================
- Hits         3334     3302      -32     
- Misses        147      187      +40     
+ Partials       53       48       -5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@wneessen
Copy link
Owner

Thanks again for the PR and the suggestion in #444!

@wneessen wneessen merged commit d962f83 into wneessen:main Mar 21, 2025
28 checks passed
@dolmen dolmen deleted the fix-Base64LineBreaker-short-writes branch April 2, 2025 15:17
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