aboutsummaryrefslogtreecommitdiff
path: root/vendor/golang.org/x/sys/windows/security_windows.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/golang.org/x/sys/windows/security_windows.go')
-rw-r--r--vendor/golang.org/x/sys/windows/security_windows.go20
1 files changed, 15 insertions, 5 deletions
diff --git a/vendor/golang.org/x/sys/windows/security_windows.go b/vendor/golang.org/x/sys/windows/security_windows.go
index 4b6eff1..9e3c44a 100644
--- a/vendor/golang.org/x/sys/windows/security_windows.go
+++ b/vendor/golang.org/x/sys/windows/security_windows.go
@@ -7,6 +7,8 @@ package windows
7import ( 7import (
8 "syscall" 8 "syscall"
9 "unsafe" 9 "unsafe"
10
11 "golang.org/x/sys/internal/unsafeheader"
10) 12)
11 13
12const ( 14const (
@@ -1229,7 +1231,7 @@ func (sd *SECURITY_DESCRIPTOR) String() string {
1229 return "" 1231 return ""
1230 } 1232 }
1231 defer LocalFree(Handle(unsafe.Pointer(sddl))) 1233 defer LocalFree(Handle(unsafe.Pointer(sddl)))
1232 return UTF16ToString((*[(1 << 30) - 1]uint16)(unsafe.Pointer(sddl))[:]) 1234 return UTF16PtrToString(sddl)
1233} 1235}
1234 1236
1235// ToAbsolute converts a self-relative security descriptor into an absolute one. 1237// ToAbsolute converts a self-relative security descriptor into an absolute one.
@@ -1307,9 +1309,17 @@ func (absoluteSD *SECURITY_DESCRIPTOR) ToSelfRelative() (selfRelativeSD *SECURIT
1307} 1309}
1308 1310
1309func (selfRelativeSD *SECURITY_DESCRIPTOR) copySelfRelativeSecurityDescriptor() *SECURITY_DESCRIPTOR { 1311func (selfRelativeSD *SECURITY_DESCRIPTOR) copySelfRelativeSecurityDescriptor() *SECURITY_DESCRIPTOR {
1310 sdBytes := make([]byte, selfRelativeSD.Length()) 1312 sdLen := (int)(selfRelativeSD.Length())
1311 copy(sdBytes, (*[(1 << 31) - 1]byte)(unsafe.Pointer(selfRelativeSD))[:len(sdBytes)]) 1313
1312 return (*SECURITY_DESCRIPTOR)(unsafe.Pointer(&sdBytes[0])) 1314 var src []byte
1315 h := (*unsafeheader.Slice)(unsafe.Pointer(&src))
1316 h.Data = unsafe.Pointer(selfRelativeSD)
1317 h.Len = sdLen
1318 h.Cap = sdLen
1319
1320 dst := make([]byte, sdLen)
1321 copy(dst, src)
1322 return (*SECURITY_DESCRIPTOR)(unsafe.Pointer(&dst[0]))
1313} 1323}
1314 1324
1315// SecurityDescriptorFromString converts an SDDL string describing a security descriptor into a 1325// SecurityDescriptorFromString converts an SDDL string describing a security descriptor into a
@@ -1391,6 +1401,6 @@ func ACLFromEntries(explicitEntries []EXPLICIT_ACCESS, mergedACL *ACL) (acl *ACL
1391 } 1401 }
1392 defer LocalFree(Handle(unsafe.Pointer(winHeapACL))) 1402 defer LocalFree(Handle(unsafe.Pointer(winHeapACL)))
1393 aclBytes := make([]byte, winHeapACL.aclSize) 1403 aclBytes := make([]byte, winHeapACL.aclSize)
1394 copy(aclBytes, (*[(1 << 31) - 1]byte)(unsafe.Pointer(winHeapACL))[:len(aclBytes)]) 1404 copy(aclBytes, (*[(1 << 31) - 1]byte)(unsafe.Pointer(winHeapACL))[:len(aclBytes):len(aclBytes)])
1395 return (*ACL)(unsafe.Pointer(&aclBytes[0])), nil 1405 return (*ACL)(unsafe.Pointer(&aclBytes[0])), nil
1396} 1406}