mirror of
https://github.com/DNSCrypt/dnscrypt-proxy.git
synced 2024-12-29 00:30:30 +01:00
fix: updateTTL guard against overflow
This commit is contained in:
parent
13e9c15212
commit
63520e494d
@ -166,8 +166,11 @@ func setMaxTTL(msg *dns.Msg, ttl uint32) {
|
||||
}
|
||||
|
||||
func updateTTL(msg *dns.Msg, expiration time.Time) {
|
||||
ttl := uint32(time.Until(expiration) / time.Second)
|
||||
|
||||
until := time.Until(expiration)
|
||||
ttl := uint32(0)
|
||||
if until > 0 {
|
||||
ttl = uint32(until / time.Second)
|
||||
}
|
||||
for _, rr := range msg.Answer {
|
||||
rr.Header().Ttl = ttl
|
||||
}
|
||||
@ -175,10 +178,8 @@ func updateTTL(msg *dns.Msg, expiration time.Time) {
|
||||
rr.Header().Ttl = ttl
|
||||
}
|
||||
for _, rr := range msg.Extra {
|
||||
header := rr.Header()
|
||||
if header.Rrtype == dns.TypeOPT {
|
||||
continue
|
||||
if rr.Header().Rrtype != dns.TypeOPT {
|
||||
rr.Header().Ttl = ttl
|
||||
}
|
||||
rr.Header().Ttl = ttl
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user