From 16a29c4a08255f8b4d8be728bd3eb80491f7c76f Mon Sep 17 00:00:00 2001 From: Ting-Wei Lan Date: Mon, 3 Aug 2020 15:58:50 +0800 Subject: [PATCH] binding: avoid 2038 problem on 32-bit architectures 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. --- binding/form_mapping.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/binding/form_mapping.go b/binding/form_mapping.go index b81ad195ce..f0913ea5e4 100644 --- a/binding/form_mapping.go +++ b/binding/form_mapping.go @@ -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 }