Skip to content

Commit

Permalink
binding: avoid 2038 problem on 32-bit architectures (#2450)
Browse files Browse the repository at this point in the history
Function setTimeField calls strconv.ParseInt with bit size 0 when
parsing Unix time, which means it is equivalent to specifying 32 on
32-bit architectures. This causes the function to suffer from the year
2038 problem. To fix it and keep the behavior the same on both 32-bit
and 64-bit architectures, explicitly specify bit size 64.

Co-authored-by: thinkerou <thinkerou@gmail.com>
  • Loading branch information
lantw44 and thinkerou committed Aug 8, 2020
1 parent cf8b583 commit 30b5f7e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion binding/form_mapping.go
Expand Up @@ -270,7 +270,7 @@ func setTimeField(val string, structField reflect.StructField, value reflect.Val

switch tf := strings.ToLower(timeFormat); tf {
case "unix", "unixnano":
tv, err := strconv.ParseInt(val, 10, 0)
tv, err := strconv.ParseInt(val, 10, 64)
if err != nil {
return err
}
Expand Down

0 comments on commit 30b5f7e

Please sign in to comment.