Skip to content

Commit

Permalink
httpcaddyfile: Don't allow i to go below zero
Browse files Browse the repository at this point in the history
  • Loading branch information
francislavoie committed Apr 2, 2021
1 parent 1c73120 commit f764d34
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion caddyconfig/httpcaddyfile/tlsapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -491,13 +491,14 @@ func consolidateAutomationPolicies(aps []*caddytls.AutomationPolicy) []*caddytls
}

// remove or combine duplicate policies
outer:
for i := 0; i < len(aps); i++ {
// compare only with next policies; we sorted by specificity so we must not delete earlier policies
for j := i + 1; j < len(aps); j++ {
// if they're exactly equal in every way, just keep one of them
if reflect.DeepEqual(aps[i], aps[j]) {
aps = append(aps[:j], aps[j+1:]...)
i--
j--
break
}

Expand All @@ -524,6 +525,7 @@ func consolidateAutomationPolicies(aps []*caddytls.AutomationPolicy) []*caddytls
if automationPolicyShadows(i, aps) >= j {
aps = append(aps[:i], aps[i+1:]...)
i--
continue outer
}
} else {
// avoid repeated subjects
Expand Down

0 comments on commit f764d34

Please sign in to comment.