"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/net/dnsclient_unix_test.go" between
go1.16.4.src.tar.gz and go1.16.5.src.tar.gz

About: Google’s Go is a compiled, garbage-collected, concurrent programming language. Latest stable release (1.16).

dnsclient_unix_test.go  (go1.16.4.src):dnsclient_unix_test.go  (go1.16.5.src)
skipping to change at line 1801 skipping to change at line 1801
} }
r := Resolver{PreferGo: true, Dial: fake.DialContext} r := Resolver{PreferGo: true, Dial: fake.DialContext}
names, err := r.lookupAddr(context.Background(), "192.0.2.123") names, err := r.lookupAddr(context.Background(), "192.0.2.123")
if err != nil { if err != nil {
t.Fatalf("LookupAddr: %v", err) t.Fatalf("LookupAddr: %v", err)
} }
if want := []string{"golang.org."}; !reflect.DeepEqual(names, want) { if want := []string{"golang.org."}; !reflect.DeepEqual(names, want) {
t.Errorf("names = %q; want %q", names, want) t.Errorf("names = %q; want %q", names, want)
} }
} }
func TestCVE202133195(t *testing.T) {
fake := fakeDNSServer{
rh: func(n, _ string, q dnsmessage.Message, _ time.Time) (dnsmess
age.Message, error) {
r := dnsmessage.Message{
Header: dnsmessage.Header{
ID: q.Header.ID,
Response: true,
RCode: dnsmessage.RCodeSucce
ss,
RecursionAvailable: true,
},
Questions: q.Questions,
}
switch q.Questions[0].Type {
case dnsmessage.TypeCNAME:
r.Answers = []dnsmessage.Resource{}
case dnsmessage.TypeA: // CNAME lookup uses a A/AAAA as a
proxy
r.Answers = append(r.Answers,
dnsmessage.Resource{
Header: dnsmessage.ResourceHeader
{
Name: dnsmessage.MustNe
wName("<html>.golang.org."),
Type: dnsmessage.TypeA,
Class: dnsmessage.ClassI
NET,
Length: 4,
},
Body: &dnsmessage.AResource{
A: TestAddr,
},
},
)
case dnsmessage.TypeSRV:
n := q.Questions[0].Name
if n.String() == "_hdr._tcp.golang.org." {
n = dnsmessage.MustNewName("<html>.golang
.org.")
}
r.Answers = append(r.Answers,
dnsmessage.Resource{
Header: dnsmessage.ResourceHeader
{
Name: n,
Type: dnsmessage.TypeSR
V,
Class: dnsmessage.ClassI
NET,
Length: 4,
},
Body: &dnsmessage.SRVResource{
Target: dnsmessage.MustNe
wName("<html>.golang.org."),
},
},
)
case dnsmessage.TypeMX:
r.Answers = append(r.Answers,
dnsmessage.Resource{
Header: dnsmessage.ResourceHeader
{
Name: dnsmessage.MustNe
wName("<html>.golang.org."),
Type: dnsmessage.TypeMX
,
Class: dnsmessage.ClassI
NET,
Length: 4,
},
Body: &dnsmessage.MXResource{
MX: dnsmessage.MustNewNam
e("<html>.golang.org."),
},
},
)
case dnsmessage.TypeNS:
r.Answers = append(r.Answers,
dnsmessage.Resource{
Header: dnsmessage.ResourceHeader
{
Name: dnsmessage.MustNe
wName("<html>.golang.org."),
Type: dnsmessage.TypeNS
,
Class: dnsmessage.ClassI
NET,
Length: 4,
},
Body: &dnsmessage.NSResource{
NS: dnsmessage.MustNewNam
e("<html>.golang.org."),
},
},
)
case dnsmessage.TypePTR:
r.Answers = append(r.Answers,
dnsmessage.Resource{
Header: dnsmessage.ResourceHeader
{
Name: dnsmessage.MustNe
wName("<html>.golang.org."),
Type: dnsmessage.TypePT
R,
Class: dnsmessage.ClassI
NET,
Length: 4,
},
Body: &dnsmessage.PTRResource{
PTR: dnsmessage.MustNewNa
me("<html>.golang.org."),
},
},
)
}
return r, nil
},
}
r := Resolver{PreferGo: true, Dial: fake.DialContext}
// Change the default resolver to match our manipulated resolver
originalDefault := DefaultResolver
DefaultResolver = &r
defer func() { DefaultResolver = originalDefault }()
// Redirect host file lookups.
defer func(orig string) { testHookHostsPath = orig }(testHookHostsPath)
testHookHostsPath = "testdata/hosts"
_, err := r.LookupCNAME(context.Background(), "golang.org")
if expected := "lookup golang.org: CNAME target is invalid"; err == nil |
| err.Error() != expected {
t.Errorf("Resolver.LookupCNAME returned unexpected error, got %q,
want %q", err, expected)
}
_, err = LookupCNAME("golang.org")
if expected := "lookup golang.org: CNAME target is invalid"; err == nil |
| err.Error() != expected {
t.Errorf("LookupCNAME returned unexpected error, got %q, want %q"
, err, expected)
}
_, _, err = r.LookupSRV(context.Background(), "target", "tcp", "golang.or
g")
if expected := "lookup golang.org: SRV target is invalid"; err == nil ||
err.Error() != expected {
t.Errorf("Resolver.LookupSRV returned unexpected error, got %q, w
ant %q", err, expected)
}
_, _, err = LookupSRV("target", "tcp", "golang.org")
if expected := "lookup golang.org: SRV target is invalid"; err == nil ||
err.Error() != expected {
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 == ni
l || err.Error() != expected {
t.Errorf("Resolver.LookupSRV returned unexpected error, got %q, w
ant %q", err, expected)
}
_, _, err = LookupSRV("hdr", "tcp", "golang.org")
if expected := "lookup golang.org: SRV header name is invalid"; err == ni
l || err.Error() != expected {
t.Errorf("LookupSRV returned unexpected error, got %q, want %q",
err, expected)
}
_, err = r.LookupMX(context.Background(), "golang.org")
if expected := "lookup golang.org: MX target is invalid"; err == nil || e
rr.Error() != expected {
t.Errorf("Resolver.LookupMX returned unexpected error, got %q, wa
nt %q", err, expected)
}
_, err = LookupMX("golang.org")
if expected := "lookup golang.org: MX target is invalid"; err == nil || e
rr.Error() != expected {
t.Errorf("LookupMX returned unexpected error, got %q, want %q", e
rr, expected)
}
_, err = r.LookupNS(context.Background(), "golang.org")
if expected := "lookup golang.org: NS target is invalid"; err == nil || e
rr.Error() != expected {
t.Errorf("Resolver.LookupNS returned unexpected error, got %q, wa
nt %q", err, expected)
}
_, err = LookupNS("golang.org")
if expected := "lookup golang.org: NS target is invalid"; err == nil || e
rr.Error() != expected {
t.Errorf("LookupNS returned unexpected error, got %q, want %q", e
rr, expected)
}
_, err = r.LookupAddr(context.Background(), "192.0.2.42")
if expected := "lookup 192.0.2.42: PTR target is invalid"; err == nil ||
err.Error() != expected {
t.Errorf("Resolver.LookupAddr returned unexpected error, got %q,
want %q", err, expected)
}
_, err = LookupAddr("192.0.2.42")
if expected := "lookup 192.0.2.42: PTR target is invalid"; err == nil ||
err.Error() != expected {
t.Errorf("LookupAddr returned unexpected error, got %q, want %q",
err, expected)
}
}
 End of changes. 1 change blocks. 
0 lines changed or deleted 0 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)