From bd8cd5441a4776e65f653de3d2c4d3d4dd2c9020 Mon Sep 17 00:00:00 2001 From: Dobes Vandermeer Date: Wed, 22 May 2019 14:21:18 -0700 Subject: [PATCH] Fix address to reference array element The address of a for loop created variable does not change between loops - the variable is over-written with each new variable. This fixes the code so that `d` references the array element instead of the local variable, which means that when `d` is assigned to `matchAll` or `specificMatch` it will work as intended. Signed-off-by: Dobes Vandermeer --- pkg/controller/acmeorders/sync.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/pkg/controller/acmeorders/sync.go b/pkg/controller/acmeorders/sync.go index 086834566..25368e9fc 100644 --- a/pkg/controller/acmeorders/sync.go +++ b/pkg/controller/acmeorders/sync.go @@ -476,8 +476,9 @@ func determineSolverConfigToUse(candidates []cmapi.ACMEChallengeSolver, authz *a var matchAll *cmapi.ACMEChallengeSolver var matchAllToSolve *acmeapi.Challenge - for _, d := range candidates { - acmech := challengeForSolver(&d) + for idx := range candidates { + d := &candidates[idx] + acmech := challengeForSolver(d) if acmech == nil { continue } @@ -486,14 +487,14 @@ func determineSolverConfigToUse(candidates []cmapi.ACMEChallengeSolver, authz *a if d.Selector == nil { if matchAll == nil { matchAllDomainsNumLabels = 0 - matchAll = &d + matchAll = d matchAllToSolve = acmech } continue } if len(d.Selector.DNSNames) == 0 { if len(d.Selector.MatchLabels) > matchAllDomainsNumLabels || matchAll == nil { - matchAll = &d + matchAll = d matchAllToSolve = acmech } } @@ -502,7 +503,7 @@ func determineSolverConfigToUse(candidates []cmapi.ACMEChallengeSolver, authz *a continue } if len(d.Selector.MatchLabels) > numLabelsSpecificMatch || specificMatch == nil { - specificMatch = &d + specificMatch = d specificMatchToSolve = acmech break }