]> Cypherpunks repositories - gostls13.git/commitdiff
net: make proto and port lookups fall back to baked-in maps on Windows
authorBrad Fitzpatrick <bradfitz@golang.org>
Thu, 29 Sep 2016 16:09:14 +0000 (09:09 -0700)
committerBrad Fitzpatrick <bradfitz@golang.org>
Thu, 29 Sep 2016 18:09:54 +0000 (18:09 +0000)
In https://golang.org/cl/28951 I cleaned up the lookupProtocol and
lookupPort paths to be consistently case-insensitive across operating
systems and to share the same baked-in maps of port & proto values
that can be relied on to exist on any platform.

I missed the fallback to the baked-in maps on Windows, though, which
broke Windows XP. This should fix it.

Fixes #17175

Change-Id: Iecd434fb684304137ee27f5521cfaa8c351a1bde
Reviewed-on: https://go-review.googlesource.com/29968
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/net/lookup_windows.go

index 9435fef8393f11dfeded7bce8e6402218879e8b7..5abfc844f7c4c20b87bc985794b9b6342bb0fc18 100644 (file)
@@ -43,7 +43,7 @@ func lookupProtocol(ctx context.Context, name string) (int, error) {
        select {
        case r := <-ch:
                if r.err != nil {
-                       if proto, ok := protocols[name]; ok {
+                       if proto, err := lookupProtocolMap(name); err == nil {
                                return proto, nil
                        }
                        r.err = &DNSError{Err: r.err.Error(), Name: name}
@@ -150,6 +150,9 @@ func lookupPort(ctx context.Context, network, service string) (int, error) {
        var result *syscall.AddrinfoW
        e := syscall.GetAddrInfoW(nil, syscall.StringToUTF16Ptr(service), &hints, &result)
        if e != nil {
+               if port, err := lookupPortMap(network, service); err == nil {
+                       return port, nil
+               }
                return 0, &DNSError{Err: os.NewSyscallError("getaddrinfow", e).Error(), Name: network + "/" + service}
        }
        defer syscall.FreeAddrInfoW(result)