]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
POrtability: use 64-bit for X-Cache-Age header
authorAmos Jeffries <squid3@treenet.co.nz>
Sat, 14 Jun 2014 01:45:50 +0000 (18:45 -0700)
committerAmos Jeffries <squid3@treenet.co.nz>
Sat, 14 Jun 2014 01:45:50 +0000 (18:45 -0700)
While the value is expected to be well within 32-bit range some OS
(OpenBSD 5.5 at least) use 64-bit time_t. Use the larger type size for
calculations which also removes 32-bit wrap errors, and cast for older
systems.

src/client_side_reply.cc

index c3ba1d153bc63c52e92c7c887013800f3d0233b2..7999d8a7f86c09be063dd74393853ac1b652f451 100644 (file)
@@ -1347,7 +1347,7 @@ clientReplyContext::buildReplyHeader()
             if (http->storeEntry()->timestamp <= squid_curtime) {
                 // put X-Cache-Age: instead of Age:
                 char age[64];
-                snprintf(age, sizeof(age), "%ld", (long int) squid_curtime - http->storeEntry()->timestamp);
+                snprintf(age, sizeof(age), "%" PRId64, static_cast<int64_t>(squid_curtime - http->storeEntry()->timestamp));
                 hdr->putExt("X-Cache-Age", age);
             }
         } else if (http->storeEntry()->timestamp <= squid_curtime) {