Debian Codegraph @

pac/client_info.go

raw symbols SCIP
1 package pac
2
3 import (
4 "encoding/binary"
5
6 "gopkg.in/jcmturner/gokrb5.v5/mstypes"
7 "gopkg.in/jcmturner/rpc.v0/ndr"
8 )
9
10 // ClientInfo implements https://msdn.microsoft.com/en-us/library/cc237951.aspx
11 type ClientInfo struct {
12 ClientID mstypes.FileTime
13 NameLength uint16
14 Name string
15 }
16
17 // Unmarshal bytes into the ClientInfo struct
18 func (k *ClientInfo) Unmarshal(b []byte) error {
19 //The PAC_CLIENT_INFO structure is a simple structure that is not NDR-encoded.
20 var p int
21 var e binary.ByteOrder = binary.LittleEndian
22
23 k.ClientID = mstypes.ReadFileTime(&b, &p, &e)
24 k.NameLength = ndr.ReadUint16(&b, &p, &e)
25 if len(b[p:]) < int(k.NameLength) {
26 return ndr.Malformed{EText: "PAC ClientInfo length truncated"}
27 }
28 k.Name = ndr.ReadUTF16String(int(k.NameLength), &b, &p, &e)
29
30 //Check that there is only zero padding left
31 if len(b) >= p {
32 for _, v := range b[p:] {
33 if v != 0 {
34 return ndr.Malformed{EText: "non-zero padding left over at end of data stream"}
35 }
36 }
37 }
38
39 return nil
40 }