<rdar://problem/7186576> Incorrect handling of uDNS records with large TTLs (over...
authorcheshire@apple.com <cheshire@apple.com@214c2c4a-bf3b-4dcf-9390-e4dd3010487d>
Thu, 17 Sep 2009 21:19:21 +0000 (21:19 +0000)
committercheshire@apple.com <cheshire@apple.com@214c2c4a-bf3b-4dcf-9390-e4dd3010487d>
Thu, 17 Sep 2009 21:19:21 +0000 (21:19 +0000)
git-svn-id: http://svn.macosforge.org/repository/mDNSResponder/trunk@6678 214c2c4a-bf3b-4dcf-9390-e4dd3010487d

mDNSCore/mDNS.c

index 599e054..8743f5e 100755 (executable)
@@ -2695,7 +2695,7 @@ mDNSlocal void CheckCacheExpiration(mDNS *const m, CacheGroup *const cg)
                if (m->timenow - event >= 0)    // If expired, delete it
                        {
                        *rp = rr->next;                         // Cut it from the list
-                       verbosedebugf("CheckCacheExpiration: Deleting%7d %4d %p %s",
+                       verbosedebugf("CheckCacheExpiration: Deleting%7d %7d %p %s",
                                m->timenow - rr->TimeRcvd, rr->resrec.rroriginalttl, rr->CRActiveQuestion, CRDisplayString(m, rr));
                        if (rr->CRActiveQuestion)       // If this record has one or more active questions, tell them it's going away
                                {
@@ -4806,8 +4806,8 @@ mDNSlocal mDNSu32 GetEffectiveTTL(const uDNS_LLQType LLQType, mDNSu32 ttl)                // T
        else    // else not LLQ (standard uDNS response)
                {
                // The TTL is already capped to a maximum value in GetLargeResourceRecord, but just to be extra safe we
-               // also do this check here to make sure we can't get integer overflow below
-               if (ttl > 0x8000000UL) ttl = 0x8000000UL;
+               // also do this check here to make sure we can't get overflow below when we add a quarter to the TTL
+               if (ttl > 0x60000000UL / mDNSPlatformOneSecond) ttl = 0x60000000UL / mDNSPlatformOneSecond;
 
                // Adjustment factor to avoid race condition:
                // Suppose real record as TTL of 3600, and our local caching server has held it for 3500 seconds, so it returns an aged TTL of 100.