添加安全检查,确保转换后的值在int类型的范围内 (#3543)

This commit is contained in:
lostmaniac 2024-01-09 17:03:36 +08:00 committed by GitHub
parent 6d03042e26
commit 625189ce85
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -193,6 +193,12 @@ func getRecycleBinDTOFromName(filename string) (*response.RecycleBinDTO, error)
if err != nil {
return nil, err
}
// 添加安全检查确保转换后的值在int类型的范围内
if size < math.MinInt || size > math.MaxInt {
return nil, fmt.Errorf("size out of int range")
}
deleteTime, err := strconv.ParseInt(matches[3], 10, 64)
if err != nil {
return nil, err