aboutsummaryrefslogtreecommitdiff
path: root/plugin
diff options
context:
space:
mode:
authorGravatar Yong Tang <yong.tang.github@outlook.com> 2022-06-26 16:06:43 -0700
committerGravatar GitHub <noreply@github.com> 2022-06-26 16:06:43 -0700
commit0218a34008f22c8c5ae4a35d0d71ef4c7a1c3c05 (patch)
tree692d799d8e8a72db72c3694200b38b8ed68a12d8 /plugin
parente0dead4aa27cada3e292d45bd65b849ca1e63255 (diff)
downloadcoredns-0218a34008f22c8c5ae4a35d0d71ef4c7a1c3c05.tar.gz
coredns-0218a34008f22c8c5ae4a35d0d71ef4c7a1c3c05.tar.zst
coredns-0218a34008f22c8c5ae4a35d0d71ef4c7a1c3c05.zip
Fix out-of-index issue in rewrite plugin (#5462)
This PR fixes another out-of-index issue in rewrite to avoid security vuln. Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
Diffstat (limited to 'plugin')
-rw-r--r--plugin/rewrite/rewrite.go3
-rw-r--r--plugin/rewrite/setup_test.go1
2 files changed, 4 insertions, 0 deletions
diff --git a/plugin/rewrite/rewrite.go b/plugin/rewrite/rewrite.go
index b676a1f2d..b28352cbd 100644
--- a/plugin/rewrite/rewrite.go
+++ b/plugin/rewrite/rewrite.go
@@ -100,6 +100,9 @@ func newRule(args ...string) (Rule, error) {
switch arg0 {
case Continue:
mode = Continue
+ if len(args) < 2 {
+ return nil, fmt.Errorf("continue rule must begin with a rule type")
+ }
ruleType = strings.ToLower(args[1])
expectNumArgs = len(args) - 1
startArg = 2
diff --git a/plugin/rewrite/setup_test.go b/plugin/rewrite/setup_test.go
index 128f3d11c..dcc10cd87 100644
--- a/plugin/rewrite/setup_test.go
+++ b/plugin/rewrite/setup_test.go
@@ -33,6 +33,7 @@ func TestParse(t *testing.T) {
name regex foo bar
}`, true, "must begin with a name rule"},
{`rewrite stop`, true, ""},
+ {`rewrite continue`, true, ""},
}
for i, test := range tests {