]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Portability: use 64-bit for X-Cache-Age header
authorAmos Jeffries <squid3@treenet.co.nz>
Sat, 21 Jun 2014 04:19:58 +0000 (22:19 -0600)
committerAmos Jeffries <squid3@treenet.co.nz>
Sat, 21 Jun 2014 04:19:58 +0000 (22:19 -0600)
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 bcd7d9118977dff7658f63cee5a50c958a8d8a9b..a297fbd9cc0bf17bb7c914397b127717b65551cc 100644 (file)
@@ -1323,7 +1323,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) {