aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/compiler/compiler_test.go
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2021-10-05 11:09:48 +0200
committerDmitry Vyukov <dvyukov@google.com>2021-10-05 15:45:04 +0200
commitd9ffc81421c7dcf20d88106c5dca34ec35cb610a (patch)
treeb3db9dc55acbfd6f175d87718a7159bb72002c52 /pkg/compiler/compiler_test.go
parent8a6b1a8da46b1f7e601339d52caa0fbb0bcdd490 (diff)
pkg/compiler: fix infinite recursion in template instantiation
Fix a bug found by OSS-Fuzz: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=17240 We handled the case of infinite recursion in templates but only if the full type name matches precisely (A -> B -> A). In this case the name constantly changes due to different template arguments. Per se this is a not an error (and we have real cases that use this, e.g. when an nlattr_t contains nested nlattr_t's), but it's an error if it recurses infinitely. Restrict recursion on the same template to 10 levels.
Diffstat (limited to 'pkg/compiler/compiler_test.go')
-rw-r--r--pkg/compiler/compiler_test.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/pkg/compiler/compiler_test.go b/pkg/compiler/compiler_test.go
index 131270939..8045bf608 100644
--- a/pkg/compiler/compiler_test.go
+++ b/pkg/compiler/compiler_test.go
@@ -135,6 +135,15 @@ func TestData(t *testing.T) {
func TestFuzz(t *testing.T) {
t.Parallel()
for _, data := range []string{
+ `
+type p b[L]
+type b[L]{
+ e b[3:L]
+ e b[2:L]
+ e b[1[L]]
+ k b[H]
+ k b[Q]
+}`,
"d~^gB̉`i\u007f?\xb0.",
"da[",
"define\x98define(define\x98define\x98define\x98define\x98define)define\tdefin",