X-Git-Url: https://ruderich.org/simon/gitweb/?p=nsscash%2Fnsscash.git;a=blobdiff_plain;f=group.go;h=4ca213a0edfabc48fd7a95e4280509c4547c9d5c;hp=126ebb0dc349e0127c4ff14f3b61f48cb99cc737;hb=a3031f694a0d58d23d383346ee848a6c78a1e4b9;hpb=7adc7f83eddd37aa372aa10159128b6d16c4320a diff --git a/group.go b/group.go index 126ebb0..4ca213a 100644 --- a/group.go +++ b/group.go @@ -26,6 +26,7 @@ import ( "sort" "strconv" "strings" + "math" "github.com/pkg/errors" ) @@ -130,6 +131,11 @@ func SerializeGroup(g Group) ([]byte, error) { } // And the group members concatenated as above data.Write(mems.Bytes()) + // Ensure the offsets can fit the length of this entry + if data.Len() > math.MaxUint16 { + return nil, fmt.Errorf("group too large to serialize: %v, %v", + data.Len(), g) + } size := uint16(data.Len()) var res bytes.Buffer // serialized result