mirror of https://github.com/gofiber/fiber.git
🩹 Fix: genericParseType parsing large uint leads to overflow (#3315)
* 🩹 Fix: genericParseType parsing large uint leads to overflow * ♻️ Refactor: use strconv.FormatUint instead of fmt.Sprintfimprove_docs
parent
b0bc32b534
commit
283ef32196
|
@ -5522,6 +5522,10 @@ func Test_GenericParseTypeUints(t *testing.T) {
|
|||
value: uint(4),
|
||||
str: "4",
|
||||
},
|
||||
{
|
||||
value: ^uint(0),
|
||||
str: strconv.FormatUint(uint64(^uint(0)), 10),
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range uints {
|
||||
|
|
|
@ -796,7 +796,7 @@ func genericParseType[V GenericType](str string, v V, defaultValue ...V) V {
|
|||
case int64:
|
||||
return genericParseInt[V](str, 64, func(i int64) V { return assertValueType[V, int64](i) }, defaultValue...)
|
||||
case uint:
|
||||
return genericParseUint[V](str, 32, func(i uint64) V { return assertValueType[V, uint](uint(i)) }, defaultValue...)
|
||||
return genericParseUint[V](str, 0, func(i uint64) V { return assertValueType[V, uint](uint(i)) }, defaultValue...)
|
||||
case uint8:
|
||||
return genericParseUint[V](str, 8, func(i uint64) V { return assertValueType[V, uint8](uint8(i)) }, defaultValue...)
|
||||
case uint16:
|
||||
|
|
Loading…
Reference in New Issue