Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix crash in pillar if NTP FQDN is an empty string #4536

Merged
merged 1 commit into from
Feb 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/pillar/devicenetwork/dns.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func ResolveWithSrcIP(domain string, dnsServerIP net.IP, srcIP net.IP) ([]DNSRes
dialer := net.Dialer{LocalAddr: &sourceUDPAddr}
dnsClient := dns.Client{Dialer: &dialer}
msg := dns.Msg{}
if domain[len(domain)-1] != '.' {
if !strings.HasSuffix(domain, ".") {
domain = domain + "."
}
msg.SetQuestion(domain, dns.TypeA)
Expand Down
12 changes: 12 additions & 0 deletions pkg/pillar/devicenetwork/dns_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,3 +285,15 @@ func TestResolveCacheWrap(t *testing.T) {
t.Fatalf("resolver func should have been called twice because different src IPs, but called=%d", called)
}
}

func FuzzResolveWithSrcIP(f *testing.F) {
f.Fuzz(func(t *testing.T,
domain string,
dnsServer string,
src string,
) {
dnsServerIP := net.ParseIP(dnsServer)
srcIP := net.ParseIP(src)
devicenetwork.ResolveWithSrcIP(domain, dnsServerIP, srcIP)
})
}
Loading