mirror of
https://github.com/rwinkhart/sys.git
synced 2026-09-06 00:57:18 -04:00
windows, unix: fix wrong unsafe.Pointer alignment in syscall
Same as CL 201877 did for package syscall. Updates golang/go#34972 Change-Id: I3929841ab32378516edafb1f02a84b1bdcc77bbd Reviewed-on: https://go-review.googlesource.com/c/sys/+/202177 Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
committed by
Tobias Klauser
parent
727590c500
commit
9984515f05
+1
-1
@@ -237,7 +237,7 @@ func anyToSockaddr(fd int, rsa *RawSockaddrAny) (Sockaddr, error) {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bytes := (*[10000]byte)(unsafe.Pointer(&pp.Path[0]))[0:n]
|
bytes := (*[len(pp.Path)]byte)(unsafe.Pointer(&pp.Path[0]))[0:n]
|
||||||
sa.Name = string(bytes)
|
sa.Name = string(bytes)
|
||||||
return sa, nil
|
return sa, nil
|
||||||
|
|
||||||
|
|||||||
@@ -884,7 +884,7 @@ func anyToSockaddr(fd int, rsa *RawSockaddrAny) (Sockaddr, error) {
|
|||||||
for n < len(pp.Path) && pp.Path[n] != 0 {
|
for n < len(pp.Path) && pp.Path[n] != 0 {
|
||||||
n++
|
n++
|
||||||
}
|
}
|
||||||
bytes := (*[10000]byte)(unsafe.Pointer(&pp.Path[0]))[0:n]
|
bytes := (*[len(pp.Path)]byte)(unsafe.Pointer(&pp.Path[0]))[0:n]
|
||||||
sa.Name = string(bytes)
|
sa.Name = string(bytes)
|
||||||
return sa, nil
|
return sa, nil
|
||||||
|
|
||||||
|
|||||||
@@ -391,7 +391,7 @@ func anyToSockaddr(fd int, rsa *RawSockaddrAny) (Sockaddr, error) {
|
|||||||
for n < len(pp.Path) && pp.Path[n] != 0 {
|
for n < len(pp.Path) && pp.Path[n] != 0 {
|
||||||
n++
|
n++
|
||||||
}
|
}
|
||||||
bytes := (*[10000]byte)(unsafe.Pointer(&pp.Path[0]))[0:n]
|
bytes := (*[len(pp.Path)]byte)(unsafe.Pointer(&pp.Path[0]))[0:n]
|
||||||
sa.Name = string(bytes)
|
sa.Name = string(bytes)
|
||||||
return sa, nil
|
return sa, nil
|
||||||
|
|
||||||
|
|||||||
@@ -229,13 +229,15 @@ func LookupSID(system, account string) (sid *SID, domain string, accType uint32,
|
|||||||
|
|
||||||
// String converts SID to a string format suitable for display, storage, or transmission.
|
// String converts SID to a string format suitable for display, storage, or transmission.
|
||||||
func (sid *SID) String() string {
|
func (sid *SID) String() string {
|
||||||
|
// From https://docs.microsoft.com/en-us/windows/win32/secbiomet/general-constants
|
||||||
|
const SecurityMaxSidSize = 68
|
||||||
var s *uint16
|
var s *uint16
|
||||||
e := ConvertSidToStringSid(sid, &s)
|
e := ConvertSidToStringSid(sid, &s)
|
||||||
if e != nil {
|
if e != nil {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
defer LocalFree((Handle)(unsafe.Pointer(s)))
|
defer LocalFree((Handle)(unsafe.Pointer(s)))
|
||||||
return UTF16ToString((*[(1 << 30) - 1]uint16)(unsafe.Pointer(s))[:])
|
return UTF16ToString((*[SecurityMaxSidSize]uint16)(unsafe.Pointer(s))[:])
|
||||||
}
|
}
|
||||||
|
|
||||||
// Len returns the length, in bytes, of a valid security identifier SID.
|
// Len returns the length, in bytes, of a valid security identifier SID.
|
||||||
|
|||||||
@@ -857,7 +857,7 @@ func (rsa *RawSockaddrAny) Sockaddr() (Sockaddr, error) {
|
|||||||
for n < len(pp.Path) && pp.Path[n] != 0 {
|
for n < len(pp.Path) && pp.Path[n] != 0 {
|
||||||
n++
|
n++
|
||||||
}
|
}
|
||||||
bytes := (*[10000]byte)(unsafe.Pointer(&pp.Path[0]))[0:n]
|
bytes := (*[len(pp.Path)]byte)(unsafe.Pointer(&pp.Path[0]))[0:n]
|
||||||
sa.Name = string(bytes)
|
sa.Name = string(bytes)
|
||||||
return sa, nil
|
return sa, nil
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user