Fix query cache module assigned time_t value to int32 variable. Change
the variable type to int64. Per Coverity. Also use difftime() to
calculate time_t difference. This is a recommended practice.
https://www.jpcert.or.jp/sc-rules/c-msc05-c.html
{
unsigned int total_length; /* total length in bytes including myself */
time_t timestamp; /* cache creation time */
- int expire; /* cache expire duration in seconds */
+ int64 expire; /* cache expire duration in seconds */
} POOL_CACHE_ITEM_HEADER;
typedef struct
if (cih->expire > 0)
{
now = time(NULL);
- if (now > (cih->timestamp + cih->expire))
+ if (difftime(now, cih->timestamp) > cih->expire)
{
ereport(DEBUG1,
(errmsg("memcache finding item"),