From c0770e6aa01c70fbefc267d9213a87066824a1ba Mon Sep 17 00:00:00 2001 From: Tom Limoncelli Date: Thu, 25 May 2023 19:41:39 -0400 Subject: [PATCH] AUTODNS: Guard against conversion errors (#2396) --- providers/autodns/autoDnsProvider.go | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/providers/autodns/autoDnsProvider.go b/providers/autodns/autoDnsProvider.go index cb371a2f8..7682118c5 100644 --- a/providers/autodns/autoDnsProvider.go +++ b/providers/autodns/autoDnsProvider.go @@ -339,10 +339,22 @@ func toRecordConfig(domain string, record *ResourceRecord) *models.RecordConfig found := re.FindStringSubmatch(record.Value) weight, _ := strconv.Atoi(found[1]) - rc.SrvWeight = uint16(weight) + if weight < 0 { + rc.SrvWeight = 0 + } else if weight > 65535 { + rc.SrvWeight = 65535 + } else { + rc.SrvWeight = uint16(weight) + } port, _ := strconv.Atoi(found[2]) - rc.SrvPort = uint16(port) + if port < 0 { + rc.SrvPort = 0 + } else if port > 65535 { + rc.SrvPort = 65535 + } else { + rc.SrvPort = uint16(port) + } rc.SetTarget(found[3]) }