1
0
mirror of https://github.com/golang/go synced 2024-11-26 06:57:56 -07:00

net: fix failure of TestCVE202133195

TestCVE202133195 fails in testing LookupSRV if /etc/resolv.conf sets the option
'ndots' larger than the number of dots in the domain name under query.

Fix the issue by making the input domain name in test codes 'rooted' to skip search
list qualifying.

Fixes #46955

Change-Id: I1909fa7e54e9c9af57623e57cafc905729ff99fa
Reviewed-on: https://go-review.googlesource.com/c/go/+/330842
Reviewed-by: Damien Neil <dneil@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Dmitri Shuralyov <dmitshur@golang.org>
This commit is contained in:
Xiangdong Ji 2021-06-28 20:27:30 +08:00 committed by Damien Neil
parent e294b8a49e
commit f9d50953b9

View File

@ -1921,12 +1921,12 @@ func TestCVE202133195(t *testing.T) {
t.Errorf("LookupSRV returned unexpected error, got %q, want %q", err, expected)
}
_, _, err = r.LookupSRV(context.Background(), "hdr", "tcp", "golang.org")
if expected := "lookup golang.org: SRV header name is invalid"; err == nil || err.Error() != expected {
_, _, err = r.LookupSRV(context.Background(), "hdr", "tcp", "golang.org.")
if expected := "lookup golang.org.: SRV header name is invalid"; err == nil || err.Error() != expected {
t.Errorf("Resolver.LookupSRV returned unexpected error, got %q, want %q", err, expected)
}
_, _, err = LookupSRV("hdr", "tcp", "golang.org")
if expected := "lookup golang.org: SRV header name is invalid"; err == nil || err.Error() != expected {
_, _, err = LookupSRV("hdr", "tcp", "golang.org.")
if expected := "lookup golang.org.: SRV header name is invalid"; err == nil || err.Error() != expected {
t.Errorf("LookupSRV returned unexpected error, got %q, want %q", err, expected)
}