Repository navigation
Conversation
The armored reader used bufio.Reader.ReadBytes, which keeps reading until it finds a newline. An input with no newline was buffered in full before the 64 column check ran, so a large armored input could exhaust memory. Use ReadSlice instead, which stops at the bufio buffer size (at least 4096 bytes, well above any valid line), and reject the line when the buffer fills. Fixes FiloSottile#756
pcarinhas
approved these changes
Nov 1, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
armor.NewReaderbuffered each line in full withReadBytesbefore the 64 column check, so input with no newline could exhaust memory. This reads withReadSliceinstead, which stops at the bufio buffer (at least 4096 bytes), and rejects the line when the buffer fills.TestLongLinefeeds a 64 MiB line before and after the header and checks that the reader fails after reading less than 1 MiB.go test ./...passes, including the CCTV vectors.Fixes #756