X-Git-Url: https://ruderich.org/simon/gitweb/?p=nsscash%2Fnsscash.git;a=blobdiff_plain;f=group.go;h=4513758df41c4a8d22eb32f8fac5653e773ca3dd;hp=b7f7d1b8e8b9c4ce71252570c5d9cc6182b972d9;hb=1d028880cfb17a7c8a9e3b1f54cf1e980baca63d;hpb=c42f577140459f548b1d7b085cd4dc2717e060c6 diff --git a/group.go b/group.go index b7f7d1b..4513758 100644 --- a/group.go +++ b/group.go @@ -114,10 +114,7 @@ func SerializeGroup(g Group) []byte { offPasswd := uint16(data.Len()) data.Write([]byte(g.Passwd)) data.WriteByte(0) - // Padding to align the following uint16 - if data.Len()%2 != 0 { - data.WriteByte(0) - } + alignBufferTo(&data, 2) // align the following uint16 offMemOff := uint16(data.Len()) // Offsets for group members offMem := offMemOff + 2*uint16(len(mems_off)) @@ -154,12 +151,7 @@ func SerializeGroup(g Group) []byte { res.Write(data.Bytes()) // We must pad each entry so that all uint64 at the beginning of the // struct are 8 byte aligned - l := res.Len() - if l%8 != 0 { - for i := 0; i < 8-l%8; i++ { - res.WriteByte(0) - } - } + alignBufferTo(&res, 8) return res.Bytes() }