Skip to content

Commit 42dc604

Browse files
Potential fix for code scanning alert no. 53: Incorrect conversion between integer types
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
1 parent 6c1a191 commit 42dc604

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

schema/avro/schema/parser_json.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ func parseType(v interface{}, s *Schema, typeName string) (interface{}, error) {
5050
if math.Trunc(val) != val {
5151
return 0, Errorf("type", "invalid type, expected %v but got %v", typeName, ToType(v))
5252
}
53+
// Ensure the value fits in a 32-bit signed integer
54+
if val < math.MinInt32 || val > math.MaxInt32 {
55+
return 0, Errorf("type", "integer value %v out of bounds for Avro int32", val)
56+
}
5357
return int(val), nil
5458
}
5559
case "long":

0 commit comments

Comments
 (0)