-
Notifications
You must be signed in to change notification settings - Fork 424
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: fix cast security issue #3243
Conversation
Signed-off-by: Song Gao <[email protected]>
Signed-off-by: Song Gao <[email protected]>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #3243 +/- ##
==========================================
- Coverage 70.85% 70.74% -0.11%
==========================================
Files 395 395
Lines 44335 44424 +89
==========================================
+ Hits 31411 31427 +16
- Misses 10430 10488 +58
- Partials 2494 2509 +15 ☔ View full report in Codecov by Sentry. |
@@ -122,6 +126,9 @@ func (fc *FieldConverter) EncodeField(field *desc.FieldDescriptor, v interface{} | |||
if err != nil { | |||
return 0, nil | |||
} else { | |||
if r > math.MaxUint32 { | |||
return 0, fmt.Errorf("value %d is out of uint32 range", v) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The same as above
@@ -174,6 +181,9 @@ func (fc *FieldConverter) encodeSingleField(field *desc.FieldDescriptor, v inter | |||
case dpb.FieldDescriptorProto_TYPE_INT32, dpb.FieldDescriptorProto_TYPE_SFIXED32, dpb.FieldDescriptorProto_TYPE_SINT32, dpb.FieldDescriptorProto_TYPE_ENUM: | |||
r, err := cast.ToInt(v, cast.CONVERT_SAMEKIND) | |||
if err == nil { | |||
if r > math.MaxInt32 { | |||
return 0, fmt.Errorf("value %d is out of int32 range", v) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The same as above
@@ -188,6 +198,9 @@ func (fc *FieldConverter) encodeSingleField(field *desc.FieldDescriptor, v inter | |||
case dpb.FieldDescriptorProto_TYPE_FIXED32, dpb.FieldDescriptorProto_TYPE_UINT32: | |||
r, err := cast.ToUint64(v, cast.CONVERT_SAMEKIND) | |||
if err == nil { | |||
if r > math.MaxUint32 { | |||
return 0, fmt.Errorf("value %d is out of uint32 range", v) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The same as above
Signed-off-by: Song Gao <[email protected]>
No description provided.