1
0
mirror of https://github.com/StackExchange/dnscontrol.git synced 2024-05-11 05:55:12 +00:00

AUTODNS: Guard against conversion errors (#2396)

This commit is contained in:
Tom Limoncelli
2023-05-25 19:41:39 -04:00
committed by GitHub
parent 260648765e
commit c0770e6aa0

View File

@@ -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])
}