File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed
Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ package configtype
33import (
44 "encoding/json"
55 "fmt"
6+ "math"
67 "regexp"
78 "strconv"
89 "time"
@@ -237,10 +238,19 @@ func (d *timeDuration) addUnit(unit string, number int64) error {
237238 case "hour" , "hours" :
238239 d .duration += time .Hour * time .Duration (number )
239240 case "day" , "days" :
241+ if number < math .MinInt || number > math .MaxInt {
242+ return fmt .Errorf ("invalid %s value: %d. Out of bounds" , unit , number )
243+ }
240244 d .days += int (number )
241245 case "month" , "months" :
246+ if number < math .MinInt || number > math .MaxInt {
247+ return fmt .Errorf ("invalid %s value: %d. Out of bounds" , unit , number )
248+ }
242249 d .months += int (number )
243250 case "year" , "years" :
251+ if number < math .MinInt || number > math .MaxInt {
252+ return fmt .Errorf ("invalid %s value: %d. Out of bounds" , unit , number )
253+ }
244254 d .years += int (number )
245255 default :
246256 return fmt .Errorf ("invalid unit: %q" , unit )
You can’t perform that action at this time.
0 commit comments