Skip to content

Commit 42a4532

Browse files
committed
chore: prevent protential int overflow
1 parent f28d67f commit 42a4532

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

v2/pkg/engine/datasource/grpc_datasource/json_builder.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -474,8 +474,10 @@ func (j *jsonBuilder) setJSONValue(arena *astjson.Arena, root *astjson.Value, na
474474
}
475475
case protoref.StringKind:
476476
root.Set(name, arena.NewString(data.Get(fd).String()))
477-
case protoref.Int32Kind, protoref.Int64Kind:
477+
case protoref.Int32Kind:
478478
root.Set(name, arena.NewNumberInt(int(data.Get(fd).Int())))
479+
case protoref.Int64Kind:
480+
root.Set(name, arena.NewNumberString(strconv.FormatInt(data.Get(fd).Int(), 10)))
479481
case protoref.Uint32Kind, protoref.Uint64Kind:
480482
root.Set(name, arena.NewNumberString(strconv.FormatUint(data.Get(fd).Uint(), 10)))
481483
case protoref.FloatKind, protoref.DoubleKind:
@@ -521,8 +523,10 @@ func (j *jsonBuilder) setArrayItem(index int, arena *astjson.Arena, array *astjs
521523
}
522524
case protoref.StringKind:
523525
array.SetArrayItem(index, arena.NewString(data.String()))
524-
case protoref.Int32Kind, protoref.Int64Kind:
526+
case protoref.Int32Kind:
525527
array.SetArrayItem(index, arena.NewNumberInt(int(data.Int())))
528+
case protoref.Int64Kind:
529+
array.SetArrayItem(index, arena.NewNumberString(strconv.FormatInt(data.Int(), 10)))
526530
case protoref.Uint32Kind, protoref.Uint64Kind:
527531
array.SetArrayItem(index, arena.NewNumberString(strconv.FormatUint(data.Uint(), 10)))
528532
case protoref.FloatKind, protoref.DoubleKind:

0 commit comments

Comments
 (0)