1
0
mirror of https://github.com/golang/go synced 2024-11-17 04:24:47 -07:00

net: use bytealg.IndexByte in cgoLookupAddrPTR

Change-Id: I76f4dc1e8bda98936c1198cb45ce8141ca88845b
Reviewed-on: https://go-review.googlesource.com/c/go/+/566235
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
Tobias Klauser 2024-02-22 22:03:50 +01:00 committed by Gopher Robot
parent 74642ddf2e
commit 51a2418f38

View File

@ -14,6 +14,7 @@ package net
import (
"context"
"errors"
"internal/bytealg"
"net/netip"
"syscall"
"unsafe"
@ -287,11 +288,8 @@ func cgoLookupAddrPTR(addr string, sa *_C_struct_sockaddr, salen _C_socklen_t) (
}
return nil, &DNSError{Err: err.Error(), Name: addr, IsTemporary: isTemporary, IsNotFound: isErrorNoSuchHost}
}
for i := 0; i < len(b); i++ {
if b[i] == 0 {
if i := bytealg.IndexByte(b, 0); i != -1 {
b = b[:i]
break
}
}
return []string{absDomainName(string(b))}, nil
}