X-Git-Url: https://ruderich.org/simon/gitweb/?a=blobdiff_plain;f=passwd.go;h=07a62d8b8667d510d395fb8b5bd4a8a0c2c55570;hb=13b90749eb1b3547bbfbb47fe142cb96a17234b5;hp=1b4939c63ac6a1a9b2c634bdd0a74a2def5f0419;hpb=d7eb5ee1a910303f38904e604aea9cf0b1372d7b;p=nsscash%2Fnsscash.git diff --git a/passwd.go b/passwd.go index 1b4939c..07a62d8 100644 --- a/passwd.go +++ b/passwd.go @@ -44,7 +44,7 @@ type Passwd struct { } // ParsePasswds parses a file in the format of /etc/passwd and returns all -// entries as Passwd structs. +// entries as slice of Passwd structs. func ParsePasswds(r io.Reader) ([]Passwd, error) { var res []Passwd @@ -134,12 +134,7 @@ func SerializePasswd(p Passwd) []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.Write([]byte{'0'}) - } - } + alignBufferTo(&res, 8) return res.Bytes() }