Skip to content

Commit

Permalink
Saved one allocation when returning SIDs
Browse files Browse the repository at this point in the history
  • Loading branch information
lkarlslund committed Jun 13, 2022
1 parent dd304ce commit 4e4e728
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions modules/windowssecurity/sid.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,11 @@ func ParseSID(data []byte) (SID, []byte, error) {
return "", data, fmt.Errorf("SID revision must be 1 (dump %x ...)", data)
}
subauthoritycount := int(data[1])
var sid = make([]byte, 8+4*subauthoritycount)
if subauthoritycount > 15 {
return "", data, errors.New("SID subauthority count is more than 15")
}
copy(sid, data[0:len(sid)])
return SID(dedup.D.S(string(sid))), data[len(sid):], nil
length := 8 + 4*subauthoritycount
return SID(dedup.D.BS(data[0:length])), data[length:], nil
}

func SIDFromString(input string) (SID, error) {
Expand Down

0 comments on commit 4e4e728

Please sign in to comment.