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:
@@ -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])
|
||||
}
|
||||
|
Reference in New Issue
Block a user