Skip to content

Commit 147fc46

Browse files
aphansal123Copilot
andauthored
Add maximum iteration limit to prevent infinite loops
Co-authored-by: Copilot <[email protected]>
1 parent 80b36bf commit 147fc46

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

internal/verification/dns.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,16 @@ func IsRetryableDNSError(err error) bool {
291291
}
292292

293293
// Use iterative approach to prevent stack overflow with deeply nested errors
294+
// Use iterative approach to prevent stack overflow with deeply nested errors
295+
const maxIterations = 100
296+
iterationCount := 0
294297
for err != nil {
298+
// Prevent infinite loop in case of circular error chain
299+
if iterationCount >= maxIterations {
300+
log.Printf("Exceeded maximum error unwrapping iterations (%d); possible circular error chain", maxIterations)
301+
return false
302+
}
303+
iterationCount++
295304
// Check for temporary network errors
296305
var netErr *net.OpError
297306
if errors.As(err, &netErr) {

0 commit comments

Comments
 (0)