mirror of
https://github.com/golang/go.git
synced 2025-05-05 23:53:05 +00:00
[dev.boringcrypto.go1.15] all: merge go1.15.14 into dev.boringcrypto.go1.15
Change-Id: Ia5ae002730c2c0e6bea5e9a10bf335af3ef23e23
This commit is contained in:
commit
ddf078e08d
@ -1556,7 +1556,7 @@ func (ctxt *Link) hostlink() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const compressDWARF = "-Wl,--compress-debug-sections=zlib-gnu"
|
const compressDWARF = "-Wl,--compress-debug-sections=zlib-gnu"
|
||||||
if ctxt.compressDWARF && linkerFlagSupported(argv[0], altLinker, compressDWARF) {
|
if ctxt.compressDWARF && linkerFlagSupported(ctxt.Arch, argv[0], altLinker, compressDWARF) {
|
||||||
argv = append(argv, compressDWARF)
|
argv = append(argv, compressDWARF)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1646,7 +1646,7 @@ func (ctxt *Link) hostlink() {
|
|||||||
if ctxt.BuildMode == BuildModeExe && !ctxt.linkShared {
|
if ctxt.BuildMode == BuildModeExe && !ctxt.linkShared {
|
||||||
// GCC uses -no-pie, clang uses -nopie.
|
// GCC uses -no-pie, clang uses -nopie.
|
||||||
for _, nopie := range []string{"-no-pie", "-nopie"} {
|
for _, nopie := range []string{"-no-pie", "-nopie"} {
|
||||||
if linkerFlagSupported(argv[0], altLinker, nopie) {
|
if linkerFlagSupported(ctxt.Arch, argv[0], altLinker, nopie) {
|
||||||
argv = append(argv, nopie)
|
argv = append(argv, nopie)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@ -1747,7 +1747,7 @@ func (ctxt *Link) hostlink() {
|
|||||||
|
|
||||||
var createTrivialCOnce sync.Once
|
var createTrivialCOnce sync.Once
|
||||||
|
|
||||||
func linkerFlagSupported(linker, altLinker, flag string) bool {
|
func linkerFlagSupported(arch *sys.Arch, linker, altLinker, flag string) bool {
|
||||||
createTrivialCOnce.Do(func() {
|
createTrivialCOnce.Do(func() {
|
||||||
src := filepath.Join(*flagTmpdir, "trivial.c")
|
src := filepath.Join(*flagTmpdir, "trivial.c")
|
||||||
if err := ioutil.WriteFile(src, []byte("int main() { return 0; }"), 0666); err != nil {
|
if err := ioutil.WriteFile(src, []byte("int main() { return 0; }"), 0666); err != nil {
|
||||||
@ -1781,7 +1781,7 @@ func linkerFlagSupported(linker, altLinker, flag string) bool {
|
|||||||
"-target",
|
"-target",
|
||||||
}
|
}
|
||||||
|
|
||||||
var flags []string
|
flags := hostlinkArchArgs(arch)
|
||||||
keep := false
|
keep := false
|
||||||
skip := false
|
skip := false
|
||||||
extldflags := strings.Fields(*flagExtldflags)
|
extldflags := strings.Fields(*flagExtldflags)
|
||||||
|
@ -434,7 +434,17 @@ func (l *Loader) AddSym(name string, ver int, r *oReader, li int, kind int, dupo
|
|||||||
if l.flags&FlagStrictDups != 0 {
|
if l.flags&FlagStrictDups != 0 {
|
||||||
l.checkdup(name, r, li, oldi)
|
l.checkdup(name, r, li, oldi)
|
||||||
}
|
}
|
||||||
return oldi, false
|
// Fix for issue #46656 -- given two dupok symbols with
|
||||||
|
// different sizes, favor symbol with larger size.
|
||||||
|
szdup := l.SymSize(oldi)
|
||||||
|
sz := int64(r.Sym(li).Siz())
|
||||||
|
if szdup >= sz {
|
||||||
|
return oldi, false
|
||||||
|
} else {
|
||||||
|
// new symbol overwrites old symbol.
|
||||||
|
l.objSyms[oldi] = objSym{r, li}
|
||||||
|
return oldi, true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
oldr, oldli := l.toLocal(oldi)
|
oldr, oldli := l.toLocal(oldi)
|
||||||
oldsym := oldr.Sym(oldli)
|
oldsym := oldr.Sym(oldli)
|
||||||
|
@ -67,7 +67,11 @@ func (ka rsaKeyAgreement) generateClientKeyExchange(config *Config, clientHello
|
|||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
encrypted, err := rsa.EncryptPKCS1v15(config.rand(), cert.PublicKey.(*rsa.PublicKey), preMasterSecret)
|
rsaKey, ok := cert.PublicKey.(*rsa.PublicKey)
|
||||||
|
if !ok {
|
||||||
|
return nil, nil, errors.New("tls: server certificate contains incorrect key type for selected ciphersuite")
|
||||||
|
}
|
||||||
|
encrypted, err := rsa.EncryptPKCS1v15(config.rand(), rsaKey, preMasterSecret)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
@ -1846,6 +1846,17 @@ func TestCVE202133195(t *testing.T) {
|
|||||||
Target: dnsmessage.MustNewName("<html>.golang.org."),
|
Target: dnsmessage.MustNewName("<html>.golang.org."),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
dnsmessage.Resource{
|
||||||
|
Header: dnsmessage.ResourceHeader{
|
||||||
|
Name: n,
|
||||||
|
Type: dnsmessage.TypeSRV,
|
||||||
|
Class: dnsmessage.ClassINET,
|
||||||
|
Length: 4,
|
||||||
|
},
|
||||||
|
Body: &dnsmessage.SRVResource{
|
||||||
|
Target: dnsmessage.MustNewName("good.golang.org."),
|
||||||
|
},
|
||||||
|
},
|
||||||
)
|
)
|
||||||
case dnsmessage.TypeMX:
|
case dnsmessage.TypeMX:
|
||||||
r.Answers = append(r.Answers,
|
r.Answers = append(r.Answers,
|
||||||
@ -1860,6 +1871,17 @@ func TestCVE202133195(t *testing.T) {
|
|||||||
MX: dnsmessage.MustNewName("<html>.golang.org."),
|
MX: dnsmessage.MustNewName("<html>.golang.org."),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
dnsmessage.Resource{
|
||||||
|
Header: dnsmessage.ResourceHeader{
|
||||||
|
Name: dnsmessage.MustNewName("good.golang.org."),
|
||||||
|
Type: dnsmessage.TypeMX,
|
||||||
|
Class: dnsmessage.ClassINET,
|
||||||
|
Length: 4,
|
||||||
|
},
|
||||||
|
Body: &dnsmessage.MXResource{
|
||||||
|
MX: dnsmessage.MustNewName("good.golang.org."),
|
||||||
|
},
|
||||||
|
},
|
||||||
)
|
)
|
||||||
case dnsmessage.TypeNS:
|
case dnsmessage.TypeNS:
|
||||||
r.Answers = append(r.Answers,
|
r.Answers = append(r.Answers,
|
||||||
@ -1874,6 +1896,17 @@ func TestCVE202133195(t *testing.T) {
|
|||||||
NS: dnsmessage.MustNewName("<html>.golang.org."),
|
NS: dnsmessage.MustNewName("<html>.golang.org."),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
dnsmessage.Resource{
|
||||||
|
Header: dnsmessage.ResourceHeader{
|
||||||
|
Name: dnsmessage.MustNewName("good.golang.org."),
|
||||||
|
Type: dnsmessage.TypeNS,
|
||||||
|
Class: dnsmessage.ClassINET,
|
||||||
|
Length: 4,
|
||||||
|
},
|
||||||
|
Body: &dnsmessage.NSResource{
|
||||||
|
NS: dnsmessage.MustNewName("good.golang.org."),
|
||||||
|
},
|
||||||
|
},
|
||||||
)
|
)
|
||||||
case dnsmessage.TypePTR:
|
case dnsmessage.TypePTR:
|
||||||
r.Answers = append(r.Answers,
|
r.Answers = append(r.Answers,
|
||||||
@ -1888,6 +1921,17 @@ func TestCVE202133195(t *testing.T) {
|
|||||||
PTR: dnsmessage.MustNewName("<html>.golang.org."),
|
PTR: dnsmessage.MustNewName("<html>.golang.org."),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
dnsmessage.Resource{
|
||||||
|
Header: dnsmessage.ResourceHeader{
|
||||||
|
Name: dnsmessage.MustNewName("good.golang.org."),
|
||||||
|
Type: dnsmessage.TypePTR,
|
||||||
|
Class: dnsmessage.ClassINET,
|
||||||
|
Length: 4,
|
||||||
|
},
|
||||||
|
Body: &dnsmessage.PTRResource{
|
||||||
|
PTR: dnsmessage.MustNewName("good.golang.org."),
|
||||||
|
},
|
||||||
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
return r, nil
|
return r, nil
|
||||||
@ -1903,57 +1947,176 @@ func TestCVE202133195(t *testing.T) {
|
|||||||
defer func(orig string) { testHookHostsPath = orig }(testHookHostsPath)
|
defer func(orig string) { testHookHostsPath = orig }(testHookHostsPath)
|
||||||
testHookHostsPath = "testdata/hosts"
|
testHookHostsPath = "testdata/hosts"
|
||||||
|
|
||||||
_, err := r.LookupCNAME(context.Background(), "golang.org")
|
tests := []struct {
|
||||||
if expected := "lookup golang.org: CNAME target is invalid"; err == nil || err.Error() != expected {
|
name string
|
||||||
t.Errorf("Resolver.LookupCNAME returned unexpected error, got %q, want %q", err, expected)
|
f func(*testing.T)
|
||||||
}
|
}{
|
||||||
_, err = LookupCNAME("golang.org")
|
{
|
||||||
if expected := "lookup golang.org: CNAME target is invalid"; err == nil || err.Error() != expected {
|
name: "CNAME",
|
||||||
t.Errorf("LookupCNAME returned unexpected error, got %q, want %q", err, expected)
|
f: func(t *testing.T) {
|
||||||
|
expectedErr := &DNSError{Err: errMalformedDNSRecordsDetail, Name: "golang.org"}
|
||||||
|
_, err := r.LookupCNAME(context.Background(), "golang.org")
|
||||||
|
if err.Error() != expectedErr.Error() {
|
||||||
|
t.Fatalf("unexpected error: %s", err)
|
||||||
|
}
|
||||||
|
_, err = LookupCNAME("golang.org")
|
||||||
|
if err.Error() != expectedErr.Error() {
|
||||||
|
t.Fatalf("unexpected error: %s", err)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "SRV (bad record)",
|
||||||
|
f: func(t *testing.T) {
|
||||||
|
expected := []*SRV{
|
||||||
|
{
|
||||||
|
Target: "good.golang.org.",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
expectedErr := &DNSError{Err: errMalformedDNSRecordsDetail, Name: "golang.org"}
|
||||||
|
_, records, err := r.LookupSRV(context.Background(), "target", "tcp", "golang.org")
|
||||||
|
if err.Error() != expectedErr.Error() {
|
||||||
|
t.Fatalf("unexpected error: %s", err)
|
||||||
|
}
|
||||||
|
if !reflect.DeepEqual(records, expected) {
|
||||||
|
t.Error("Unexpected record set")
|
||||||
|
}
|
||||||
|
_, records, err = LookupSRV("target", "tcp", "golang.org")
|
||||||
|
if err.Error() != expectedErr.Error() {
|
||||||
|
t.Errorf("unexpected error: %s", err)
|
||||||
|
}
|
||||||
|
if !reflect.DeepEqual(records, expected) {
|
||||||
|
t.Error("Unexpected record set")
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "SRV (bad header)",
|
||||||
|
f: func(t *testing.T) {
|
||||||
|
_, _, 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 {
|
||||||
|
t.Errorf("LookupSRV returned unexpected error, got %q, want %q", err, expected)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "MX",
|
||||||
|
f: func(t *testing.T) {
|
||||||
|
expected := []*MX{
|
||||||
|
{
|
||||||
|
Host: "good.golang.org.",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
expectedErr := &DNSError{Err: errMalformedDNSRecordsDetail, Name: "golang.org"}
|
||||||
|
records, err := r.LookupMX(context.Background(), "golang.org")
|
||||||
|
if err.Error() != expectedErr.Error() {
|
||||||
|
t.Fatalf("unexpected error: %s", err)
|
||||||
|
}
|
||||||
|
if !reflect.DeepEqual(records, expected) {
|
||||||
|
t.Error("Unexpected record set")
|
||||||
|
}
|
||||||
|
records, err = LookupMX("golang.org")
|
||||||
|
if err.Error() != expectedErr.Error() {
|
||||||
|
t.Fatalf("unexpected error: %s", err)
|
||||||
|
}
|
||||||
|
if !reflect.DeepEqual(records, expected) {
|
||||||
|
t.Error("Unexpected record set")
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "NS",
|
||||||
|
f: func(t *testing.T) {
|
||||||
|
expected := []*NS{
|
||||||
|
{
|
||||||
|
Host: "good.golang.org.",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
expectedErr := &DNSError{Err: errMalformedDNSRecordsDetail, Name: "golang.org"}
|
||||||
|
records, err := r.LookupNS(context.Background(), "golang.org")
|
||||||
|
if err.Error() != expectedErr.Error() {
|
||||||
|
t.Fatalf("unexpected error: %s", err)
|
||||||
|
}
|
||||||
|
if !reflect.DeepEqual(records, expected) {
|
||||||
|
t.Error("Unexpected record set")
|
||||||
|
}
|
||||||
|
records, err = LookupNS("golang.org")
|
||||||
|
if err.Error() != expectedErr.Error() {
|
||||||
|
t.Fatalf("unexpected error: %s", err)
|
||||||
|
}
|
||||||
|
if !reflect.DeepEqual(records, expected) {
|
||||||
|
t.Error("Unexpected record set")
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Addr",
|
||||||
|
f: func(t *testing.T) {
|
||||||
|
expected := []string{"good.golang.org."}
|
||||||
|
expectedErr := &DNSError{Err: errMalformedDNSRecordsDetail, Name: "192.0.2.42"}
|
||||||
|
records, err := r.LookupAddr(context.Background(), "192.0.2.42")
|
||||||
|
if err.Error() != expectedErr.Error() {
|
||||||
|
t.Fatalf("unexpected error: %s", err)
|
||||||
|
}
|
||||||
|
if !reflect.DeepEqual(records, expected) {
|
||||||
|
t.Error("Unexpected record set")
|
||||||
|
}
|
||||||
|
records, err = LookupAddr("192.0.2.42")
|
||||||
|
if err.Error() != expectedErr.Error() {
|
||||||
|
t.Fatalf("unexpected error: %s", err)
|
||||||
|
}
|
||||||
|
if !reflect.DeepEqual(records, expected) {
|
||||||
|
t.Error("Unexpected record set")
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
_, _, err = r.LookupSRV(context.Background(), "target", "tcp", "golang.org")
|
for _, tc := range tests {
|
||||||
if expected := "lookup golang.org: SRV target is invalid"; err == nil || err.Error() != expected {
|
t.Run(tc.name, tc.f)
|
||||||
t.Errorf("Resolver.LookupSRV returned unexpected error, got %q, want %q", err, expected)
|
}
|
||||||
}
|
}
|
||||||
_, _, err = LookupSRV("target", "tcp", "golang.org")
|
|
||||||
if expected := "lookup golang.org: SRV target is invalid"; err == nil || err.Error() != expected {
|
func TestNullMX(t *testing.T) {
|
||||||
t.Errorf("LookupSRV returned unexpected error, got %q, want %q", err, expected)
|
fake := fakeDNSServer{
|
||||||
}
|
rh: func(n, _ string, q dnsmessage.Message, _ time.Time) (dnsmessage.Message, error) {
|
||||||
|
r := dnsmessage.Message{
|
||||||
_, _, err = r.LookupSRV(context.Background(), "hdr", "tcp", "golang.org")
|
Header: dnsmessage.Header{
|
||||||
if expected := "lookup golang.org: SRV header name is invalid"; err == nil || err.Error() != expected {
|
ID: q.Header.ID,
|
||||||
t.Errorf("Resolver.LookupSRV returned unexpected error, got %q, want %q", err, expected)
|
Response: true,
|
||||||
}
|
RCode: dnsmessage.RCodeSuccess,
|
||||||
_, _, err = LookupSRV("hdr", "tcp", "golang.org")
|
},
|
||||||
if expected := "lookup golang.org: SRV header name is invalid"; err == nil || err.Error() != expected {
|
Questions: q.Questions,
|
||||||
t.Errorf("LookupSRV returned unexpected error, got %q, want %q", err, expected)
|
Answers: []dnsmessage.Resource{
|
||||||
}
|
{
|
||||||
|
Header: dnsmessage.ResourceHeader{
|
||||||
_, err = r.LookupMX(context.Background(), "golang.org")
|
Name: q.Questions[0].Name,
|
||||||
if expected := "lookup golang.org: MX target is invalid"; err == nil || err.Error() != expected {
|
Type: dnsmessage.TypeMX,
|
||||||
t.Errorf("Resolver.LookupMX returned unexpected error, got %q, want %q", err, expected)
|
Class: dnsmessage.ClassINET,
|
||||||
}
|
},
|
||||||
_, err = LookupMX("golang.org")
|
Body: &dnsmessage.MXResource{
|
||||||
if expected := "lookup golang.org: MX target is invalid"; err == nil || err.Error() != expected {
|
MX: dnsmessage.MustNewName("."),
|
||||||
t.Errorf("LookupMX returned unexpected error, got %q, want %q", err, expected)
|
},
|
||||||
}
|
},
|
||||||
|
},
|
||||||
_, err = r.LookupNS(context.Background(), "golang.org")
|
}
|
||||||
if expected := "lookup golang.org: NS target is invalid"; err == nil || err.Error() != expected {
|
return r, nil
|
||||||
t.Errorf("Resolver.LookupNS returned unexpected error, got %q, want %q", err, expected)
|
},
|
||||||
}
|
}
|
||||||
_, err = LookupNS("golang.org")
|
r := Resolver{PreferGo: true, Dial: fake.DialContext}
|
||||||
if expected := "lookup golang.org: NS target is invalid"; err == nil || err.Error() != expected {
|
rrset, err := r.LookupMX(context.Background(), "golang.org")
|
||||||
t.Errorf("LookupNS returned unexpected error, got %q, want %q", err, expected)
|
if err != nil {
|
||||||
}
|
t.Fatalf("LookupMX: %v", err)
|
||||||
|
}
|
||||||
_, err = r.LookupAddr(context.Background(), "192.0.2.42")
|
if want := []*MX{&MX{Host: "."}}; !reflect.DeepEqual(rrset, want) {
|
||||||
if expected := "lookup 192.0.2.42: PTR target is invalid"; err == nil || err.Error() != expected {
|
records := []string{}
|
||||||
t.Errorf("Resolver.LookupAddr returned unexpected error, got %q, want %q", err, expected)
|
for _, rr := range rrset {
|
||||||
}
|
records = append(records, fmt.Sprintf("%v", rr))
|
||||||
_, err = LookupAddr("192.0.2.42")
|
}
|
||||||
if expected := "lookup 192.0.2.42: PTR target is invalid"; err == nil || err.Error() != expected {
|
t.Errorf("records = [%v]; want [%v]", strings.Join(records, " "), want[0])
|
||||||
t.Errorf("LookupAddr returned unexpected error, got %q, want %q", err, expected)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -415,7 +415,7 @@ func (r *Resolver) LookupCNAME(ctx context.Context, host string) (string, error)
|
|||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
if !isDomainName(cname) {
|
if !isDomainName(cname) {
|
||||||
return "", &DNSError{Err: "CNAME target is invalid", Name: host}
|
return "", &DNSError{Err: errMalformedDNSRecordsDetail, Name: host}
|
||||||
}
|
}
|
||||||
return cname, nil
|
return cname, nil
|
||||||
}
|
}
|
||||||
@ -431,7 +431,9 @@ func (r *Resolver) LookupCNAME(ctx context.Context, host string) (string, error)
|
|||||||
// and proto are empty strings, LookupSRV looks up name directly.
|
// and proto are empty strings, LookupSRV looks up name directly.
|
||||||
//
|
//
|
||||||
// The returned service names are validated to be properly
|
// The returned service names are validated to be properly
|
||||||
// formatted presentation-format domain names.
|
// formatted presentation-format domain names. If the response contains
|
||||||
|
// invalid names, those records are filtered out and an error
|
||||||
|
// will be returned alongside the the remaining results, if any.
|
||||||
func LookupSRV(service, proto, name string) (cname string, addrs []*SRV, err error) {
|
func LookupSRV(service, proto, name string) (cname string, addrs []*SRV, err error) {
|
||||||
return DefaultResolver.LookupSRV(context.Background(), service, proto, name)
|
return DefaultResolver.LookupSRV(context.Background(), service, proto, name)
|
||||||
}
|
}
|
||||||
@ -447,7 +449,9 @@ func LookupSRV(service, proto, name string) (cname string, addrs []*SRV, err err
|
|||||||
// and proto are empty strings, LookupSRV looks up name directly.
|
// and proto are empty strings, LookupSRV looks up name directly.
|
||||||
//
|
//
|
||||||
// The returned service names are validated to be properly
|
// The returned service names are validated to be properly
|
||||||
// formatted presentation-format domain names.
|
// formatted presentation-format domain names. If the response contains
|
||||||
|
// invalid names, those records are filtered out and an error
|
||||||
|
// will be returned alongside the the remaining results, if any.
|
||||||
func (r *Resolver) LookupSRV(ctx context.Context, service, proto, name string) (string, []*SRV, error) {
|
func (r *Resolver) LookupSRV(ctx context.Context, service, proto, name string) (string, []*SRV, error) {
|
||||||
cname, addrs, err := r.lookupSRV(ctx, service, proto, name)
|
cname, addrs, err := r.lookupSRV(ctx, service, proto, name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -456,21 +460,31 @@ func (r *Resolver) LookupSRV(ctx context.Context, service, proto, name string) (
|
|||||||
if cname != "" && !isDomainName(cname) {
|
if cname != "" && !isDomainName(cname) {
|
||||||
return "", nil, &DNSError{Err: "SRV header name is invalid", Name: name}
|
return "", nil, &DNSError{Err: "SRV header name is invalid", Name: name}
|
||||||
}
|
}
|
||||||
|
filteredAddrs := make([]*SRV, 0, len(addrs))
|
||||||
for _, addr := range addrs {
|
for _, addr := range addrs {
|
||||||
if addr == nil {
|
if addr == nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if !isDomainName(addr.Target) {
|
if !isDomainName(addr.Target) {
|
||||||
return "", nil, &DNSError{Err: "SRV target is invalid", Name: name}
|
continue
|
||||||
}
|
}
|
||||||
|
filteredAddrs = append(filteredAddrs, addr)
|
||||||
}
|
}
|
||||||
return cname, addrs, nil
|
if len(addrs) != len(filteredAddrs) {
|
||||||
|
return cname, filteredAddrs, &DNSError{Err: errMalformedDNSRecordsDetail, Name: name}
|
||||||
|
}
|
||||||
|
return cname, filteredAddrs, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// LookupMX returns the DNS MX records for the given domain name sorted by preference.
|
// LookupMX returns the DNS MX records for the given domain name sorted by preference.
|
||||||
//
|
//
|
||||||
// The returned mail server names are validated to be properly
|
// The returned mail server names are validated to be properly
|
||||||
// formatted presentation-format domain names.
|
// formatted presentation-format domain names. If the response contains
|
||||||
|
// invalid names, those records are filtered out and an error
|
||||||
|
// will be returned alongside the the remaining results, if any.
|
||||||
|
//
|
||||||
|
// LookupMX uses context.Background internally; to specify the context, use
|
||||||
|
// Resolver.LookupMX.
|
||||||
func LookupMX(name string) ([]*MX, error) {
|
func LookupMX(name string) ([]*MX, error) {
|
||||||
return DefaultResolver.LookupMX(context.Background(), name)
|
return DefaultResolver.LookupMX(context.Background(), name)
|
||||||
}
|
}
|
||||||
@ -478,27 +492,41 @@ func LookupMX(name string) ([]*MX, error) {
|
|||||||
// LookupMX returns the DNS MX records for the given domain name sorted by preference.
|
// LookupMX returns the DNS MX records for the given domain name sorted by preference.
|
||||||
//
|
//
|
||||||
// The returned mail server names are validated to be properly
|
// The returned mail server names are validated to be properly
|
||||||
// formatted presentation-format domain names.
|
// formatted presentation-format domain names. If the response contains
|
||||||
|
// invalid names, those records are filtered out and an error
|
||||||
|
// will be returned alongside the the remaining results, if any.
|
||||||
func (r *Resolver) LookupMX(ctx context.Context, name string) ([]*MX, error) {
|
func (r *Resolver) LookupMX(ctx context.Context, name string) ([]*MX, error) {
|
||||||
records, err := r.lookupMX(ctx, name)
|
records, err := r.lookupMX(ctx, name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
filteredMX := make([]*MX, 0, len(records))
|
||||||
for _, mx := range records {
|
for _, mx := range records {
|
||||||
if mx == nil {
|
if mx == nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if !isDomainName(mx.Host) {
|
// Bypass the hostname validity check for targets which contain only a dot,
|
||||||
return nil, &DNSError{Err: "MX target is invalid", Name: name}
|
// as this is used to represent a 'Null' MX record.
|
||||||
|
if mx.Host != "." && !isDomainName(mx.Host) {
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
|
filteredMX = append(filteredMX, mx)
|
||||||
}
|
}
|
||||||
return records, nil
|
if len(records) != len(filteredMX) {
|
||||||
|
return filteredMX, &DNSError{Err: errMalformedDNSRecordsDetail, Name: name}
|
||||||
|
}
|
||||||
|
return filteredMX, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// LookupNS returns the DNS NS records for the given domain name.
|
// LookupNS returns the DNS NS records for the given domain name.
|
||||||
//
|
//
|
||||||
// The returned name server names are validated to be properly
|
// The returned name server names are validated to be properly
|
||||||
// formatted presentation-format domain names.
|
// formatted presentation-format domain names. If the response contains
|
||||||
|
// invalid names, those records are filtered out and an error
|
||||||
|
// will be returned alongside the the remaining results, if any.
|
||||||
|
//
|
||||||
|
// LookupNS uses context.Background internally; to specify the context, use
|
||||||
|
// Resolver.LookupNS.
|
||||||
func LookupNS(name string) ([]*NS, error) {
|
func LookupNS(name string) ([]*NS, error) {
|
||||||
return DefaultResolver.LookupNS(context.Background(), name)
|
return DefaultResolver.LookupNS(context.Background(), name)
|
||||||
}
|
}
|
||||||
@ -506,21 +534,28 @@ func LookupNS(name string) ([]*NS, error) {
|
|||||||
// LookupNS returns the DNS NS records for the given domain name.
|
// LookupNS returns the DNS NS records for the given domain name.
|
||||||
//
|
//
|
||||||
// The returned name server names are validated to be properly
|
// The returned name server names are validated to be properly
|
||||||
// formatted presentation-format domain names.
|
// formatted presentation-format domain names. If the response contains
|
||||||
|
// invalid names, those records are filtered out and an error
|
||||||
|
// will be returned alongside the the remaining results, if any.
|
||||||
func (r *Resolver) LookupNS(ctx context.Context, name string) ([]*NS, error) {
|
func (r *Resolver) LookupNS(ctx context.Context, name string) ([]*NS, error) {
|
||||||
records, err := r.lookupNS(ctx, name)
|
records, err := r.lookupNS(ctx, name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
filteredNS := make([]*NS, 0, len(records))
|
||||||
for _, ns := range records {
|
for _, ns := range records {
|
||||||
if ns == nil {
|
if ns == nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if !isDomainName(ns.Host) {
|
if !isDomainName(ns.Host) {
|
||||||
return nil, &DNSError{Err: "NS target is invalid", Name: name}
|
continue
|
||||||
}
|
}
|
||||||
|
filteredNS = append(filteredNS, ns)
|
||||||
}
|
}
|
||||||
return records, nil
|
if len(records) != len(filteredNS) {
|
||||||
|
return filteredNS, &DNSError{Err: errMalformedDNSRecordsDetail, Name: name}
|
||||||
|
}
|
||||||
|
return filteredNS, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// LookupTXT returns the DNS TXT records for the given domain name.
|
// LookupTXT returns the DNS TXT records for the given domain name.
|
||||||
@ -537,7 +572,8 @@ func (r *Resolver) LookupTXT(ctx context.Context, name string) ([]string, error)
|
|||||||
// of names mapping to that address.
|
// of names mapping to that address.
|
||||||
//
|
//
|
||||||
// The returned names are validated to be properly formatted presentation-format
|
// The returned names are validated to be properly formatted presentation-format
|
||||||
// domain names.
|
// domain names. If the response contains invalid names, those records are filtered
|
||||||
|
// out and an error will be returned alongside the the remaining results, if any.
|
||||||
//
|
//
|
||||||
// When using the host C library resolver, at most one result will be
|
// When using the host C library resolver, at most one result will be
|
||||||
// returned. To bypass the host resolver, use a custom Resolver.
|
// returned. To bypass the host resolver, use a custom Resolver.
|
||||||
@ -549,16 +585,26 @@ func LookupAddr(addr string) (names []string, err error) {
|
|||||||
// of names mapping to that address.
|
// of names mapping to that address.
|
||||||
//
|
//
|
||||||
// The returned names are validated to be properly formatted presentation-format
|
// The returned names are validated to be properly formatted presentation-format
|
||||||
// domain names.
|
// domain names. If the response contains invalid names, those records are filtered
|
||||||
|
// out and an error will be returned alongside the the remaining results, if any.
|
||||||
func (r *Resolver) LookupAddr(ctx context.Context, addr string) ([]string, error) {
|
func (r *Resolver) LookupAddr(ctx context.Context, addr string) ([]string, error) {
|
||||||
names, err := r.lookupAddr(ctx, addr)
|
names, err := r.lookupAddr(ctx, addr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
filteredNames := make([]string, 0, len(names))
|
||||||
for _, name := range names {
|
for _, name := range names {
|
||||||
if !isDomainName(name) {
|
if isDomainName(name) {
|
||||||
return nil, &DNSError{Err: "PTR target is invalid", Name: addr}
|
filteredNames = append(filteredNames, name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return names, nil
|
if len(names) != len(filteredNames) {
|
||||||
|
return filteredNames, &DNSError{Err: errMalformedDNSRecordsDetail, Name: addr}
|
||||||
|
}
|
||||||
|
return filteredNames, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// errMalformedDNSRecordsDetail is the DNSError detail which is returned when a Resolver.Lookup...
|
||||||
|
// method recieves DNS records which contain invalid DNS names. This may be returned alongside
|
||||||
|
// results which have had the malformed records filtered out.
|
||||||
|
var errMalformedDNSRecordsDetail = "DNS response contained records which contain invalid names"
|
||||||
|
@ -318,6 +318,7 @@ func TestGroupCleanupUserNamespace(t *testing.T) {
|
|||||||
"uid=0(root) gid=0(root) groups=0(root),65534",
|
"uid=0(root) gid=0(root) groups=0(root),65534",
|
||||||
"uid=0(root) gid=0(root) groups=0(root),65534(nobody),65534(nobody),65534(nobody),65534(nobody),65534(nobody),65534(nobody),65534(nobody),65534(nobody),65534(nobody),65534(nobody)", // Alpine; see https://golang.org/issue/19938
|
"uid=0(root) gid=0(root) groups=0(root),65534(nobody),65534(nobody),65534(nobody),65534(nobody),65534(nobody),65534(nobody),65534(nobody),65534(nobody),65534(nobody),65534(nobody)", // Alpine; see https://golang.org/issue/19938
|
||||||
"uid=0(root) gid=0(root) groups=0(root) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023", // CentOS with SELinux context, see https://golang.org/issue/34547
|
"uid=0(root) gid=0(root) groups=0(root) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023", // CentOS with SELinux context, see https://golang.org/issue/34547
|
||||||
|
"uid=0(root) gid=0(root) groups=0(root),65534(nobody) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023", // Fedora with SElinux context, see https://golang.org/issue/46752
|
||||||
}
|
}
|
||||||
for _, e := range expected {
|
for _, e := range expected {
|
||||||
if strOut == e {
|
if strOut == e {
|
||||||
|
64
test/fixedbugs/issue46653.dir/bad/bad.go
Normal file
64
test/fixedbugs/issue46653.dir/bad/bad.go
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
// Copyright 2021 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package a
|
||||||
|
|
||||||
|
func Bad() {
|
||||||
|
m := make(map[int64]A)
|
||||||
|
a := m[0]
|
||||||
|
if len(a.B.C1.D2.E2.F1) != 0 ||
|
||||||
|
len(a.B.C1.D2.E2.F2) != 0 ||
|
||||||
|
len(a.B.C1.D2.E2.F3) != 0 ||
|
||||||
|
len(a.B.C1.D2.E2.F4) != 0 ||
|
||||||
|
len(a.B.C1.D2.E2.F5) != 0 ||
|
||||||
|
len(a.B.C1.D2.E2.F6) != 0 ||
|
||||||
|
len(a.B.C1.D2.E2.F7) != 0 ||
|
||||||
|
len(a.B.C1.D2.E2.F8) != 0 ||
|
||||||
|
len(a.B.C1.D2.E2.F9) != 0 ||
|
||||||
|
len(a.B.C1.D2.E2.F10) != 0 ||
|
||||||
|
len(a.B.C1.D2.E2.F11) != 0 ||
|
||||||
|
len(a.B.C1.D2.E2.F16) != 0 {
|
||||||
|
panic("bad")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type A struct {
|
||||||
|
B
|
||||||
|
}
|
||||||
|
|
||||||
|
type B struct {
|
||||||
|
C1 C
|
||||||
|
C2 C
|
||||||
|
}
|
||||||
|
|
||||||
|
type C struct {
|
||||||
|
D1 D
|
||||||
|
D2 D
|
||||||
|
}
|
||||||
|
|
||||||
|
type D struct {
|
||||||
|
E1 E
|
||||||
|
E2 E
|
||||||
|
E3 E
|
||||||
|
E4 E
|
||||||
|
}
|
||||||
|
|
||||||
|
type E struct {
|
||||||
|
F1 string
|
||||||
|
F2 string
|
||||||
|
F3 string
|
||||||
|
F4 string
|
||||||
|
F5 string
|
||||||
|
F6 string
|
||||||
|
F7 string
|
||||||
|
F8 string
|
||||||
|
F9 string
|
||||||
|
F10 string
|
||||||
|
F11 string
|
||||||
|
F12 string
|
||||||
|
F13 string
|
||||||
|
F14 string
|
||||||
|
F15 string
|
||||||
|
F16 string
|
||||||
|
}
|
27
test/fixedbugs/issue46653.dir/main.go
Normal file
27
test/fixedbugs/issue46653.dir/main.go
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
// Copyright 2021 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
bad "issue46653.dir/bad"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
bad.Bad()
|
||||||
|
}
|
||||||
|
|
||||||
|
func neverCalled() L {
|
||||||
|
m := make(map[string]L)
|
||||||
|
return m[""]
|
||||||
|
}
|
||||||
|
|
||||||
|
type L struct {
|
||||||
|
A Data
|
||||||
|
B Data
|
||||||
|
}
|
||||||
|
|
||||||
|
type Data struct {
|
||||||
|
F1 [22][]string
|
||||||
|
}
|
10
test/fixedbugs/issue46653.go
Normal file
10
test/fixedbugs/issue46653.go
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
// runindir
|
||||||
|
|
||||||
|
// Copyright 2021 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// Test to verify compiler and linker handling of multiple
|
||||||
|
// competing map.zero symbol definitions.
|
||||||
|
|
||||||
|
package ignored
|
Loading…
x
Reference in New Issue
Block a user