Skip to content

Fix panic for dual-stack network as path endpoint in print-path#56

Merged
Drachionix merged 1 commit intohknutzen:masterfrom
ayhamnashar:master
Mar 18, 2026
Merged

Fix panic for dual-stack network as path endpoint in print-path#56
Drachionix merged 1 commit intohknutzen:masterfrom
ayhamnashar:master

Conversation

@ayhamnashar
Copy link
Copy Markdown
Contributor

When a dual-stack network is given as endpoint, expandGroup returns both IPv4 and IPv6 halves. The code always picked elements[0] (IPv4), causing a nil pointer panic when the other endpoint was IPv6-only. Fix: after both endpoints are known, swap to the matching IP version via combined46.

Comment thread go/pkg/pass1/print-path.go Outdated
}
// If one side is a dual-stack (combined46) network, pick the part
// that matches the IP version of the other side.
if i == 1 {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this inside of the loop over params? I think it should be placed after it so we don't need to check for the second iteration.

Comment thread go/pkg/pass1/print-path.go Outdated
Comment on lines +85 to +89
if l[0].isCombined46() && l[0].isIPv6() != l[1].isIPv6() {
l[0] = l[0].combined46
}
if l[1].isCombined46() && l[1].isIPv6() != l[0].isIPv6() {
l[1] = l[1].combined46
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those lines are almost the same and should be simplified.

@Drachionix Drachionix merged commit 8dea739 into hknutzen:master Mar 18, 2026
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