You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
funcserialize(v, v2interface{}, buf []byte) (n, flagsuint8) {
switchvv:=v.(type) {
// omit many casesdefault:
// Special case: string literal is compared with a variable of// user type with string underlying type:// type Name string// var name Name// if name == "foo" { ... }if_, ok:=v2.(string); ok {
s:=*(*string)((*iface)(unsafe.Pointer(&v)).val) // <--------iflen(s) <=SonarMaxLen {
returnuint8(copy(buf[:], s)), SonarString
}
}
// ...
I think this code contains a faulty assumption. If v has an interface type (as with reflect.DeepEqual), it can be compared with a string without itself being a string. The iface conversion is thus unsafe. I believe in this case it is due to a nil interface being compared with a string, causing a nil pointer dereference when reading the iface.val field.
If anyone cares (unlikely), this should be made safer, probably by using reflect.Type.
The text was updated successfully, but these errors were encountered:
While fuzzing something, I got this crash:
The relevant reflect.DeepEqual code is:
The relevant sonar.go line is:
I think this code contains a faulty assumption. If v has an interface type (as with reflect.DeepEqual), it can be compared with a string without itself being a string. The iface conversion is thus unsafe. I believe in this case it is due to a nil interface being compared with a string, causing a nil pointer dereference when reading the
iface.val
field.If anyone cares (unlikely), this should be made safer, probably by using reflect.Type.
The text was updated successfully, but these errors were encountered: