summaryrefslogtreecommitdiffstats
path: root/llgo/third_party/gofrontend/libgo/go/syscall/security_windows.go
diff options
context:
space:
mode:
authorAndrew Wilkins <axwalk@gmail.com>2016-03-15 05:36:43 +0000
committerAndrew Wilkins <axwalk@gmail.com>2016-03-15 05:36:43 +0000
commit6436a4abd7a2f3a60b230453295dba199d8a59c3 (patch)
tree125aef80fc2cf46c5d1758a8ece1fde14e7b13fd /llgo/third_party/gofrontend/libgo/go/syscall/security_windows.go
parent36761bf92427846ce40fdd849615732c852e44dd (diff)
downloadbcm5719-llvm-6436a4abd7a2f3a60b230453295dba199d8a59c3.tar.gz
bcm5719-llvm-6436a4abd7a2f3a60b230453295dba199d8a59c3.zip
[llgo] Roll gofrontend forward
Switch gofrontend to using go.googlesource.com, and update to 81eb6a3f425b2158c67ee32c0cc973a72ce9d6be. There are various changes required to update to the go 1.5 runtime: typemap.go is changed to accommodate the change in representation for equal/hash algorithms, and the removal of the zero value/type. CMakeLists.txt is updated to add the build tree to the package search path, so internal packages, which are not installed, are found. various files changes due to removal of __go_new_nopointers; the same change as in D11863, but with NoUnwindAttribute added to the added runtime functions which are called with "callOnly". minor cleanups in ssa.go while investigating issues with unwinding/panic handling. Differential Revisision: http://reviews.llvm.org/D15188 llvm-svn: 263536
Diffstat (limited to 'llgo/third_party/gofrontend/libgo/go/syscall/security_windows.go')
-rw-r--r--llgo/third_party/gofrontend/libgo/go/syscall/security_windows.go98
1 files changed, 45 insertions, 53 deletions
diff --git a/llgo/third_party/gofrontend/libgo/go/syscall/security_windows.go b/llgo/third_party/gofrontend/libgo/go/syscall/security_windows.go
index b22ecf578e0..1625b07ae4b 100644
--- a/llgo/third_party/gofrontend/libgo/go/syscall/security_windows.go
+++ b/llgo/third_party/gofrontend/libgo/go/syscall/security_windows.go
@@ -41,21 +41,20 @@ func TranslateAccountName(username string, from, to uint32, initSize int) (strin
if e != nil {
return "", e
}
- b := make([]uint16, 50)
- n := uint32(len(b))
- e = TranslateName(u, from, to, &b[0], &n)
- if e != nil {
+ n := uint32(50)
+ for {
+ b := make([]uint16, n)
+ e = TranslateName(u, from, to, &b[0], &n)
+ if e == nil {
+ return UTF16ToString(b[:n]), nil
+ }
if e != ERROR_INSUFFICIENT_BUFFER {
return "", e
}
- // make receive buffers of requested size and try again
- b = make([]uint16, n)
- e = TranslateName(u, from, to, &b[0], &n)
- if e != nil {
+ if n <= uint32(len(b)) {
return "", e
}
}
- return UTF16ToString(b), nil
}
const (
@@ -136,26 +135,23 @@ func LookupSID(system, account string) (sid *SID, domain string, accType uint32,
return nil, "", 0, e
}
}
- db := make([]uint16, 50)
- dn := uint32(len(db))
- b := make([]byte, 50)
- n := uint32(len(b))
- sid = (*SID)(unsafe.Pointer(&b[0]))
- e = LookupAccountName(sys, acc, sid, &n, &db[0], &dn, &accType)
- if e != nil {
+ n := uint32(50)
+ dn := uint32(50)
+ for {
+ b := make([]byte, n)
+ db := make([]uint16, dn)
+ sid = (*SID)(unsafe.Pointer(&b[0]))
+ e = LookupAccountName(sys, acc, sid, &n, &db[0], &dn, &accType)
+ if e == nil {
+ return sid, UTF16ToString(db), accType, nil
+ }
if e != ERROR_INSUFFICIENT_BUFFER {
return nil, "", 0, e
}
- // make receive buffers of requested size and try again
- b = make([]byte, n)
- sid = (*SID)(unsafe.Pointer(&b[0]))
- db = make([]uint16, dn)
- e = LookupAccountName(sys, acc, sid, &n, &db[0], &dn, &accType)
- if e != nil {
+ if n <= uint32(len(b)) {
return nil, "", 0, e
}
}
- return sid, UTF16ToString(db), accType, nil
}
// String converts sid to a string format
@@ -197,24 +193,22 @@ func (sid *SID) LookupAccount(system string) (account, domain string, accType ui
return "", "", 0, err
}
}
- b := make([]uint16, 50)
- n := uint32(len(b))
- db := make([]uint16, 50)
- dn := uint32(len(db))
- e := LookupAccountSid(sys, sid, &b[0], &n, &db[0], &dn, &accType)
- if e != nil {
+ n := uint32(50)
+ dn := uint32(50)
+ for {
+ b := make([]uint16, n)
+ db := make([]uint16, dn)
+ e := LookupAccountSid(sys, sid, &b[0], &n, &db[0], &dn, &accType)
+ if e == nil {
+ return UTF16ToString(b), UTF16ToString(db), accType, nil
+ }
if e != ERROR_INSUFFICIENT_BUFFER {
return "", "", 0, e
}
- // make receive buffers of requested size and try again
- b = make([]uint16, n)
- db = make([]uint16, dn)
- e = LookupAccountSid(nil, sid, &b[0], &n, &db[0], &dn, &accType)
- if e != nil {
+ if n <= uint32(len(b)) {
return "", "", 0, e
}
}
- return UTF16ToString(b), UTF16ToString(db), accType, nil
}
const (
@@ -326,21 +320,20 @@ func (t Token) Close() error {
// getInfo retrieves a specified type of information about an access token.
func (t Token) getInfo(class uint32, initSize int) (unsafe.Pointer, error) {
- b := make([]byte, initSize)
- var n uint32
- e := GetTokenInformation(t, class, &b[0], uint32(len(b)), &n)
- if e != nil {
+ n := uint32(initSize)
+ for {
+ b := make([]byte, n)
+ e := GetTokenInformation(t, class, &b[0], uint32(len(b)), &n)
+ if e == nil {
+ return unsafe.Pointer(&b[0]), nil
+ }
if e != ERROR_INSUFFICIENT_BUFFER {
return nil, e
}
- // make receive buffers of requested size and try again
- b = make([]byte, n)
- e = GetTokenInformation(t, class, &b[0], uint32(len(b)), &n)
- if e != nil {
+ if n <= uint32(len(b)) {
return nil, e
}
}
- return unsafe.Pointer(&b[0]), nil
}
// GetTokenUser retrieves access token t user account information.
@@ -366,19 +359,18 @@ func (t Token) GetTokenPrimaryGroup() (*Tokenprimarygroup, error) {
// GetUserProfileDirectory retrieves path to the
// root directory of the access token t user's profile.
func (t Token) GetUserProfileDirectory() (string, error) {
- b := make([]uint16, 100)
- n := uint32(len(b))
- e := GetUserProfileDirectory(t, &b[0], &n)
- if e != nil {
+ n := uint32(100)
+ for {
+ b := make([]uint16, n)
+ e := GetUserProfileDirectory(t, &b[0], &n)
+ if e == nil {
+ return UTF16ToString(b), nil
+ }
if e != ERROR_INSUFFICIENT_BUFFER {
return "", e
}
- // make receive buffers of requested size and try again
- b = make([]uint16, n)
- e = GetUserProfileDirectory(t, &b[0], &n)
- if e != nil {
+ if n <= uint32(len(b)) {
return "", e
}
}
- return UTF16ToString(b), nil
}
OpenPOWER on IntegriCloud