diff options
author | Alexander Pevzner <pzz@apevzner.com> | 2020-01-15 08:36:36 +0300 |
---|---|---|
committer | Alexander Pevzner <pzz@apevzner.com> | 2020-01-15 08:36:36 +0300 |
commit | 74ba02a50126dcc32d9fa74d30a81d55d802dbe8 (patch) | |
tree | 05dbbdb9555e0905fc62af99678cd9a8fb8c1e34 | |
parent | eb91691349f9e0c74c449999d2008fd06fe1bbe6 (diff) |
Fixed enforcing of size limits of Attribute Name and Value
-rw-r--r-- | encoder.go | 10 |
1 files changed, 6 insertions, 4 deletions
@@ -125,8 +125,9 @@ func (me *messageEncoder) encodeTag(tag Tag) error { // Encode Attribute name func (me *messageEncoder) encodeName(name string) error { - if len(name) > math.MaxUint16 { - return fmt.Errorf("Attribute name exceeds %d bytes", len(name)) + if len(name) > math.MaxInt16 { + return fmt.Errorf("Attribute name exceeds %d bytes", + math.MaxInt16) } err := me.encodeU16(uint16(len(name))) @@ -159,8 +160,9 @@ func (me *messageEncoder) encodeValue(tag Tag, v Value) error { return err } - if len(data) > math.MaxUint16 { - return fmt.Errorf("Attribute value exceeds %d bytes", len(data)) + if len(data) > math.MaxInt16 { + return fmt.Errorf("Attribute value exceeds %d bytes", + math.MaxInt16) } err = me.encodeU16(uint16(len(data))) |