Fix stack buffer overflow in IPv6 parsing with IPv4 dotted notation#28
Open
rustyconover wants to merge 3 commits into
Open
Fix stack buffer overflow in IPv6 parsing with IPv4 dotted notation#28rustyconover wants to merge 3 commits into
rustyconover wants to merge 3 commits into
Conversation
…764349a126f53de0728c9f Apply patches from duckdb/duckdb
When parsing IPv6 addresses containing IPv4 dotted decimal notation (e.g., 'a:b:c:d:e:f:a:1.2.3.4'), the IPv4 portion writes two quibbles into the quibbles array. The loop condition only checks parsed_quibble_count < 8, so if we enter with count=7, the first write at index 7 is valid but the second at index 8 overflows the stack buffer. Add a bounds check before writing the two IPv4-derived quibbles to ensure parsed_quibble_count + 2 <= IPV6_NUM_QUIBBLE, returning an error if there is insufficient room. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.
Summary
a:b:c:d:e:f:a:1.2.3.4), the IPv4 portion writes two quibbles into a stack-allocated array of size 8. The loop condition only checksparsed_quibble_count < 8, so if we enter with count=7, the first write at index 7 is valid but the second at index 8 overflows the stack buffer.parsed_quibble_count + 2 > IPV6_NUM_QUIBBLE) before writing the two IPv4-derived quibbles, returning an appropriate error message.Reproduction
Test plan
statement errora:b:c:d:e:f:1.2.3.4(6 quibbles + IPv4 = 8 total) still works correctly::ffff:1.2.3.4still works correctly🤖 Generated with Claude Code