data: return an error for too large numbers in ParseDuration (#22163)

This commit is contained in:
Wei-Lun Li authored and GitHub committed 2026-11-05 19:36:49 +00:00
1 parent b5d0152014
commit 9a0b9e0eb5
3 files changed
+13 -1

No files matched your search

+7
View File
@@ -0,0 +1,7 @@
Bugfix: Report an error for too large numbers in `--keep-within*` durations
Restic crashed with a stack trace when a number in a duration such as the one
passed to `restic forget --keep-within` did not fit into an integer. It now
reports an invalid argument instead.
https://github.com/restic/restic/pull/22163
+1 -1
View File
@@ -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 {
+5
View File
@@ -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 {