mirror of
https://github.com/restic/restic.git
synced 2026-11-06 15:29:21 +00:00
data: return an error for too large numbers in ParseDuration (#22163)
This commit is contained in:
1 parent
b5d0152014
commit
9a0b9e0eb5
3 files changed
+13
-1
No files matched your search
@@ -65,7 +65,7 @@ func nextNumber(input string) (num int, rest string, err error) {
|
||||
|
||||
num, err = strconv.Atoi(n)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
return 0, input, err
|
||||
}
|
||||
|
||||
if negative {
|
||||
|
||||
@@ -40,6 +40,9 @@ func TestNextNumber(t *testing.T) {
|
||||
{
|
||||
input: "5", num: 5, rest: "",
|
||||
},
|
||||
{
|
||||
input: "99999999999999999999999999y", num: 0, rest: "99999999999999999999999999y", err: true,
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
@@ -82,6 +85,8 @@ func TestParseDuration(t *testing.T) {
|
||||
{input: "1y4m3w1d", err: true},
|
||||
{input: "s", err: true},
|
||||
{input: "\xdf\x80", err: true}, // NKO DIGIT ZERO; we want ASCII digits
|
||||
{input: "99999999999999999999999999y", err: true},
|
||||
{input: "1y-99999999999999999999999999d", err: true},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
|
||||
Reference in new issue
Block a user