]> granicus.if.org Git - postgresql/commitdiff
pg_upgrade: fix off-by-one mistake in snprintf
authorAlvaro Herrera <alvherre@alvh.no-ip.org>
Fri, 29 Jun 2012 03:37:27 +0000 (23:37 -0400)
committerAlvaro Herrera <alvherre@alvh.no-ip.org>
Fri, 29 Jun 2012 03:37:27 +0000 (23:37 -0400)
snprintf counts trailing NUL towards the char limit.  Failing to account
for that was causing an invalid value to be passed to pg_resetxlog -l,
aborting the upgrade process.

contrib/pg_upgrade/controldata.c

index 5d5ab854ca8323d726359d9edfa52d162d8b2e65..7da19c6c28bd7f1990a5be51f355096993acf87f 100644 (file)
@@ -425,7 +425,7 @@ get_control_data(ClusterInfo *cluster, bool live_check)
        {
                if (got_log_id && got_log_seg)
                {
-                       snprintf(cluster->controldata.nextxlogfile, 24, "%08X%08X%08X",
+                       snprintf(cluster->controldata.nextxlogfile, 25, "%08X%08X%08X",
                                         tli, logid, segno);
                        got_nextxlogfile = true;
                }