mirror of
https://github.com/golang/go
synced 2024-11-17 02:04:48 -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:
parent
74642ddf2e
commit
51a2418f38
@ -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 {
|
||||
b = b[:i]
|
||||
break
|
||||
}
|
||||
if i := bytealg.IndexByte(b, 0); i != -1 {
|
||||
b = b[:i]
|
||||
}
|
||||
return []string{absDomainName(string(b))}, nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user