mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-12 20:13:59 +02:00
@@ -264,10 +264,14 @@ func Seq(args ...interface{}) ([]int, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// sanity check
|
||||||
|
if last < -100000 {
|
||||||
|
return nil, errors.New("size of result exeeds limit")
|
||||||
|
}
|
||||||
size := int(((last - first) / inc) + 1)
|
size := int(((last - first) / inc) + 1)
|
||||||
|
|
||||||
// sanity check
|
// sanity check
|
||||||
if size > 2000 {
|
if size <= 0 || size > 2000 {
|
||||||
return nil, errors.New("size of result exeeds limit")
|
return nil, errors.New("size of result exeeds limit")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -8,6 +8,11 @@ import (
|
|||||||
|
|
||||||
// Test for bugs discovered by https://github.com/dvyukov/go-fuzz
|
// Test for bugs discovered by https://github.com/dvyukov/go-fuzz
|
||||||
func TestTplGoFuzzReports(t *testing.T) {
|
func TestTplGoFuzzReports(t *testing.T) {
|
||||||
|
|
||||||
|
// The following test case(s) also fail
|
||||||
|
// See https://github.com/golang/go/issues/10634
|
||||||
|
//{"{{ seq 433937734937734969526500969526500 }}", 2}}
|
||||||
|
|
||||||
for i, this := range []struct {
|
for i, this := range []struct {
|
||||||
data string
|
data string
|
||||||
expectErr int
|
expectErr int
|
||||||
@@ -17,7 +22,8 @@ func TestTplGoFuzzReports(t *testing.T) {
|
|||||||
// Issue #1090
|
// Issue #1090
|
||||||
{"{{ slicestr \"000000\" 10}}", 2},
|
{"{{ slicestr \"000000\" 10}}", 2},
|
||||||
// Issue #1091
|
// Issue #1091
|
||||||
{"{{apply .C \"first\" 0 0 0}}", 2}} {
|
{"{{apply .C \"first\" 0 0 0}}", 2},
|
||||||
|
{"{{seq 3e80}}", 2}} {
|
||||||
templ := New()
|
templ := New()
|
||||||
|
|
||||||
d := &Data{
|
d := &Data{
|
||||||
@@ -26,6 +32,9 @@ func TestTplGoFuzzReports(t *testing.T) {
|
|||||||
C: []int{1, 2, 3},
|
C: []int{1, 2, 3},
|
||||||
D: map[int]string{1: "foo", 2: "bar"},
|
D: map[int]string{1: "foo", 2: "bar"},
|
||||||
E: Data1{42, "foo"},
|
E: Data1{42, "foo"},
|
||||||
|
F: []string{"a", "b", "c"},
|
||||||
|
G: []string{"a", "b", "c", "d", "e"},
|
||||||
|
H: "a,b,c,d,e,f",
|
||||||
}
|
}
|
||||||
|
|
||||||
err := templ.AddTemplate("fuzz", this.data)
|
err := templ.AddTemplate("fuzz", this.data)
|
||||||
@@ -52,6 +61,9 @@ type Data struct {
|
|||||||
C []int
|
C []int
|
||||||
D map[int]string
|
D map[int]string
|
||||||
E Data1
|
E Data1
|
||||||
|
F []string
|
||||||
|
G []string
|
||||||
|
H string
|
||||||
}
|
}
|
||||||
|
|
||||||
type Data1 struct {
|
type Data1 struct {
|
||||||
|
Reference in New Issue
Block a user