Fix strftime() usage in pool_pools().
authorTatsuo Ishii <ishii@postgresql.org>
Fri, 22 Nov 2013 13:04:02 +0000 (22:04 +0900)
committerTatsuo Ishii <ishii@postgresql.org>
Fri, 22 Nov 2013 13:05:52 +0000 (22:05 +0900)
The buffer is not large enough as expected by the second parameter.
This is not harmless because the format string will not produce longer
result string than the buffer.

Per Coverity report 1111426 "Out-of-bounds access".

pool_process_reporting.c

index b5c148af53f1f1e1d3ccfc3ee582bad5e106e84b..fb5c680a2e59383f4fff6aed7a03663e8b140b78 100644 (file)
@@ -878,11 +878,11 @@ void pools_reporting(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backend)
                        snprintf(proc_pid, sizeof(proc_pid), "%d", pools[i].pool_pid);
                        snprintf(pool_id, sizeof(pool_id), "%d", pools[i].pool_id);
                        if (pools[i].start_time)
-                               strftime(proc_start_time, POOLCONFIG_MAXDATELEN, "%Y-%m-%d %H:%M:%S", localtime(&pools[i].start_time));
+                               strftime(proc_start_time, sizeof(proc_start_time), "%Y-%m-%d %H:%M:%S", localtime(&pools[i].start_time));
                        else
                                *proc_start_time = '\0';
                        if (pools[i].create_time)
-                               strftime(proc_create_time, POOLCONFIG_MAXDATELEN, "%Y-%m-%d %H:%M:%S", localtime(&pools[i].create_time));
+                               strftime(proc_create_time, sizeof(proc_create_time), "%Y-%m-%d %H:%M:%S", localtime(&pools[i].create_time));
                        else
                                *proc_create_time = '\0';
                        snprintf(majorversion, sizeof(majorversion), "%d", pools[i].pool_majorversion);