Skip to content

Commit

Permalink
Merge pull request #4 from jcmturner/issue-3
Browse files Browse the repository at this point in the history
memory use improvement
  • Loading branch information
jcmturner authored Nov 12, 2020
2 parents ff5be05 + 9ea1799 commit 7f48206
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
go: [ '1.11.x', '1.12.x', '1.13.x' ]
go: [ '1.13.x', '1.14.x', '1.15.x' ]
steps:
- name: Set up Go ${{ matrix.go }}
uses: actions/setup-go@v1
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/testingv2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
go: [ '1.11.x', '1.12.x', '1.13.x' ]
go: [ '1.13.x', '1.14.x', '1.15.x' ]
steps:
- name: Set up Go ${{ matrix.go }}
uses: actions/setup-go@v1
Expand Down
16 changes: 10 additions & 6 deletions v2/mstypes/sid.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import (
"encoding/binary"
"encoding/hex"
"fmt"
"math"
"strings"
)

// RPCSID implements https://msdn.microsoft.com/en-us/library/cc230364.aspx
Expand All @@ -16,17 +18,19 @@ type RPCSID struct {

// String returns the string representation of the RPC_SID.
func (s *RPCSID) String() string {
var str string
var strb strings.Builder
strb.WriteString("S-1-")

b := append(make([]byte, 2, 2), s.IdentifierAuthority[:]...)
// For a strange reason this is read big endian: https://msdn.microsoft.com/en-us/library/dd302645.aspx
i := binary.BigEndian.Uint64(b)
if i >= 4294967296 {
str = fmt.Sprintf("S-1-0x%s", hex.EncodeToString(s.IdentifierAuthority[:]))
if i > math.MaxUint32 {
fmt.Fprintf(&strb, "0x%s", hex.EncodeToString(s.IdentifierAuthority[:]))
} else {
str = fmt.Sprintf("S-1-%d", i)
fmt.Fprintf(&strb, "%d", i)
}
for _, sub := range s.SubAuthority {
str = fmt.Sprintf("%s-%d", str, sub)
fmt.Fprintf(&strb, "-%d", sub)
}
return str
return strb.String()
}

0 comments on commit 7f48206

Please sign in to comment.