Fix problem, ignoring error in EventDataStringToBytesByType
While it converts string of bytes data, it assumes that it's empty
byte if length of the string is less then 3. Because of it, it
may pass empty bytes without error if its length is smaller than 3.
So, let it return error on other cases.
@@ -439,10 +439,7 @@ func EventDataStringToBytesByType(t string, v string) ([]byte, error) {
case "str":
return []byte(v), nil
case "bytes":
- if len(v) < 3 {
- return []byte{}, nil
- }
- if v[0:2] != "0x" {
+ if len(v) < 2 || v[0:2] != "0x" {
return nil, errors.Errorf("IllegalFormatForBytes(%s)", v)
}
return hex.DecodeString(v[2:])
