mirror of
https://github.com/StackExchange/dnscontrol.git
synced 2025-10-09 21:36:22 +08:00
AUTODNS: Guard against conversion errors (#2396)
This commit is contained in:
parent
260648765e
commit
c0770e6aa0
1 changed files with 14 additions and 2 deletions
|
@ -339,10 +339,22 @@ func toRecordConfig(domain string, record *ResourceRecord) *models.RecordConfig
|
||||||
found := re.FindStringSubmatch(record.Value)
|
found := re.FindStringSubmatch(record.Value)
|
||||||
|
|
||||||
weight, _ := strconv.Atoi(found[1])
|
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])
|
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])
|
rc.SetTarget(found[3])
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue