From be190fdb0d43592a3c8304fa4a1919a685e10b72 Mon Sep 17 00:00:00 2001 From: bep Date: Thu, 30 Apr 2015 11:41:25 +0200 Subject: [PATCH] tpl: check for too many arguments in apply Fixes #1091 --- tpl/template_funcs.go | 2 ++ tpl/template_test.go | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/tpl/template_funcs.go b/tpl/template_funcs.go index 4e07d8f39..9a446d094 100644 --- a/tpl/template_funcs.go +++ b/tpl/template_funcs.go @@ -668,6 +668,8 @@ func applyFnToThis(fn, this reflect.Value, args ...interface{}) (reflect.Value, if len(args) < num { return reflect.ValueOf(nil), errors.New("Too few arguments") + } else if len(args) > num { + return reflect.ValueOf(nil), errors.New("Too many arguments") } res := fn.Call(n) diff --git a/tpl/template_test.go b/tpl/template_test.go index 87f3cac81..c7cd20f55 100644 --- a/tpl/template_test.go +++ b/tpl/template_test.go @@ -15,7 +15,9 @@ func TestTplGoFuzzReports(t *testing.T) { // Issue #1089 {"{{apply .C \"first\" }}", 2}, // Issue #1090 - {"{{ slicestr \"000000\" 10}}", 2}} { + {"{{ slicestr \"000000\" 10}}", 2}, + // Issue #1091 + {"{{apply .C \"first\" 0 0 0}}", 2}} { templ := New() d := &Data{