return res, nil
}
-func SerializeGroup(g Group) []byte {
+func SerializeGroup(g Group) ([]byte, error) {
le := binary.LittleEndian
// Concatenate all (NUL-terminated) strings and store the offsets
// struct are 8 byte aligned
alignBufferTo(&res, 8)
- return res.Bytes()
+ return res.Bytes(), nil
}
func SerializeGroups(w io.Writer, grs []Group) error {
for _, g := range grs {
// TODO: warn about duplicate entries
offsets[toKey(g)] = uint64(data.Len())
- data.Write(SerializeGroup(g))
+ x, err := SerializeGroup(g)
+ if err != nil {
+ return err
+ }
+ data.Write(x)
}
// Copy to prevent sorting from modifying the argument
return res, nil
}
-func SerializePasswd(p Passwd) []byte {
+func SerializePasswd(p Passwd) ([]byte, error) {
// Concatenate all (NUL-terminated) strings and store the offsets
var data bytes.Buffer
data.Write([]byte(p.Name))
// struct are 8 byte aligned
alignBufferTo(&res, 8)
- return res.Bytes()
+ return res.Bytes(), nil
}
func SerializePasswds(w io.Writer, pws []Passwd) error {
for _, p := range pws {
// TODO: warn about duplicate entries
offsets[p] = uint64(data.Len())
- data.Write(SerializePasswd(p))
+ x, err := SerializePasswd(p)
+ if err != nil {
+ return err
+ }
+ data.Write(x)
}
// Copy to prevent sorting from modifying the argument