From 503a306982ec3c6ef926cd41a91e382dc9950cf4 Mon Sep 17 00:00:00 2001 From: Amos Jeffries Date: Fri, 20 Jun 2014 22:19:58 -0600 Subject: [PATCH] Portability: use 64-bit for X-Cache-Age header 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 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client_side_reply.cc b/src/client_side_reply.cc index bcd7d91189..a297fbd9cc 100644 --- a/src/client_side_reply.cc +++ b/src/client_side_reply.cc @@ -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(squid_curtime - http->storeEntry()->timestamp)); hdr->putExt("X-Cache-Age", age); } } else if (http->storeEntry()->timestamp <= squid_curtime) { -- 2.47.2