The release of GCC 7 is approaching [0], and the number of warnings in
PostgreSQL has gone up since we last looked [1].  Output attached.  (My
version is 7.0.1 20170408.)

Most of the issues have to do with concatenating two or more strings of
potential size MAXPGPATH into another buffer of size MAXPGPATH, which
could lead to truncation.

Possible fixes:

a) Ignore, hoping GCC will change before final release. (unlikely at
this point)

b) Add compiler option to disable this particular warning, worry about
it later.  (Might be an option for backpatching.)

c) Expand the target buffer sizes until the warning goes away.  (Sample
patch attached.)

d) Replace most of the problematic code with psprintf() and dynamically
sized buffers.

Comments?


[0]: https://gcc.gnu.org/ml/gcc/2017-03/msg00066.html
[1]:
https://www.postgresql.org/message-id/CAFj8pRA=xV0_-aDF5UtGVY8HGvg+ovA_js_P8z4jLHxvX0Wa=a...@mail.gmail.com

-- 
Peter Eisentraut              http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
In file included from /usr/include/stdio.h:498:0,
                 from ../../src/include/c.h:81,
                 from ../../src/include/postgres_fe.h:25,
                 from file_utils.c:15:
file_utils.c: In function 'walkdir.constprop':
file_utils.c:177:32: warning: '__builtin_snprintf' output may be truncated 
before the last format character [-Wformat-truncation=]
   snprintf(subpath, MAXPGPATH, "%s/%s", path, de->d_name);
                                ^
file_utils.c:177:3: note: '__builtin_snprintf' output 2 or more bytes (assuming 
1025) into a destination of size 1024
   snprintf(subpath, MAXPGPATH, "%s/%s", path, de->d_name);
   ^
In file included from /usr/include/stdio.h:498:0,
                 from ../../src/include/c.h:81,
                 from ../../src/include/postgres.h:47,
                 from pgtz.c:13:
pgtz.c: In function 'pg_tzenumerate_next':
pgtz.c:432:33: warning: '__builtin_snprintf' output may be truncated before the 
last format character [-Wformat-truncation=]
   snprintf(fullname, MAXPGPATH, "%s/%s",
                                 ^
pgtz.c:432:3: note: '__builtin_snprintf' output 2 or more bytes (assuming 1025) 
into a destination of size 1024
   snprintf(fullname, MAXPGPATH, "%s/%s",
   ^
In file included from /usr/include/stdio.h:498:0,
                 from ../../../../src/include/c.h:81,
                 from ../../../../src/include/postgres.h:47,
                 from rewriteheap.c:103:
rewriteheap.c: In function 'CheckPointLogicalRewriteHeap':
rewriteheap.c:1237:29: warning: '%s' directive output may be truncated writing 
up to 1023 bytes into a region of size 1004 [-Wformat-truncation=]
   snprintf(path, MAXPGPATH, "pg_logical/mappings/%s", mapping_de->d_name);
                             ^
rewriteheap.c:1237:3: note: '__builtin_snprintf' output between 21 and 1044 
bytes into a destination of size 1024
   snprintf(path, MAXPGPATH, "pg_logical/mappings/%s", mapping_de->d_name);
   ^
In file included from /usr/include/stdio.h:498:0,
                 from ../../../../src/include/c.h:81,
                 from ../../../../src/include/postgres.h:47,
                 from xlog.c:15:
xlog.c: In function 'do_pg_start_backup':
xlog.c:10403:41: warning: '%s' directive output may be truncated writing up to 
1023 bytes into a region of size 1014 [-Wformat-truncation=]
    snprintf(fullpath, sizeof(fullpath), "pg_tblspc/%s", de->d_name);
                                         ^
xlog.c:10403:4: note: '__builtin_snprintf' output between 11 and 1034 bytes 
into a destination of size 1024
    snprintf(fullpath, sizeof(fullpath), "pg_tblspc/%s", de->d_name);
    ^
xlog.c: In function 'do_pg_stop_backup':
../../../../src/include/access/xlog_internal.h:131:20: warning: '%s' directive 
output may be truncated writing up to 1023 bytes into a region of size 1017 
[-Wformat-truncation=]
 #define XLOGDIR    "pg_wal"
                    ^
xlog.c:4123:31: note: in expansion of macro 'XLOGDIR'
     snprintf(path, MAXPGPATH, XLOGDIR "/%s", xlde->d_name);
                               ^~~~~~~
In file included from xlog.c:35:0:
../../../../src/include/access/xlog_internal.h:203:38: note: format string is 
defined here
  snprintf(path, MAXPGPATH, XLOGDIR "/%08X%08X%08X.%08X.backup", tli, \
                                      ^~
In file included from /usr/include/stdio.h:498:0,
                 from ../../../../src/include/c.h:81,
                 from ../../../../src/include/postgres.h:47,
                 from xlog.c:15:
xlog.c:4123:5: note: '__builtin_snprintf' output between 8 and 1031 bytes into 
a destination of size 1024
     snprintf(path, MAXPGPATH, XLOGDIR "/%s", xlde->d_name);
     ^
In file included from /usr/include/stdio.h:498:0,
                 from ../../../src/include/c.h:81,
                 from ../../../src/include/postgres.h:47,
                 from pgstat.c:19:
pgstat.c: In function 'pgstat_reset_remove_files':
pgstat.c:639:30: warning: '__builtin_snprintf' output may be truncated before 
the last format character [-Wformat-truncation=]
   snprintf(fname, MAXPGPATH, "%s/%s", directory,
                              ^
pgstat.c:639:3: note: '__builtin_snprintf' output 2 or more bytes (assuming 
1025) into a destination of size 1024
   snprintf(fname, MAXPGPATH, "%s/%s", directory,
   ^
In file included from /usr/include/stdio.h:498:0,
                 from ../../../../src/include/c.h:81,
                 from ../../../../src/include/postgres.h:47,
                 from reorderbuffer.c:48:
reorderbuffer.c: In function 'StartupReorderBuffer':
reorderbuffer.c:2630:17: warning: '%s' directive writing up to 1023 bytes into 
a region of size 1012 [-Wformat-overflow=]
   sprintf(path, "pg_replslot/%s", logical_de->d_name);
                 ^
reorderbuffer.c:2630:3: note: '__builtin___sprintf_chk' output between 13 and 
1036 bytes into a destination of size 1024
   sprintf(path, "pg_replslot/%s", logical_de->d_name);
   ^
reorderbuffer.c:2646:19: warning: '%s' directive writing up to 1023 bytes into 
a region of size 1012 [-Wformat-overflow=]
     sprintf(path, "pg_replslot/%s/%s", logical_de->d_name,
                   ^
reorderbuffer.c:2646:5: note: '__builtin___sprintf_chk' output between 14 and 
2060 bytes into a destination of size 1024
     sprintf(path, "pg_replslot/%s/%s", logical_de->d_name,
     ^
In file included from /usr/include/stdio.h:498:0,
                 from ../../../../src/include/c.h:81,
                 from ../../../../src/include/postgres.h:47,
                 from snapbuild.c:107:
snapbuild.c: In function 'CheckPointSnapBuild':
snapbuild.c:1898:29: warning: '%s' directive output may be truncated writing up 
to 1023 bytes into a region of size 1003 [-Wformat-truncation=]
   snprintf(path, MAXPGPATH, "pg_logical/snapshots/%s", snap_de->d_name);
                             ^
snapbuild.c:1898:3: note: '__builtin_snprintf' output between 22 and 1045 bytes 
into a destination of size 1024
   snprintf(path, MAXPGPATH, "pg_logical/snapshots/%s", snap_de->d_name);
   ^
In file included from /usr/include/stdio.h:498:0,
                 from ../../../src/include/c.h:81,
                 from ../../../src/include/postgres.h:47,
                 from basebackup.c:13:
basebackup.c: In function 'sendDir':
basebackup.c:1014:32: warning: '__builtin_snprintf' output may be truncated 
before the last format character [-Wformat-truncation=]
   snprintf(pathbuf, MAXPGPATH, "%s/%s", path, de->d_name);
                                ^
basebackup.c:1014:3: note: '__builtin_snprintf' output 2 or more bytes 
(assuming 1025) into a destination of size 1024
   snprintf(pathbuf, MAXPGPATH, "%s/%s", path, de->d_name);
   ^
In file included from /usr/include/stdio.h:498:0,
                 from ../../../src/include/c.h:81,
                 from ../../../src/include/postgres.h:47,
                 from slot.c:37:
slot.c: In function 'StartupReplicationSlots':
slot.c:1032:29: warning: '%s' directive output may be truncated writing up to 
1023 bytes into a region of size 1012 [-Wformat-truncation=]
   snprintf(path, MAXPGPATH, "pg_replslot/%s", replication_de->d_name);
                             ^
slot.c:1032:3: note: '__builtin_snprintf' output between 13 and 1036 bytes into 
a destination of size 1024
   snprintf(path, MAXPGPATH, "pg_replslot/%s", replication_de->d_name);
   ^
slot.c:1271:16: warning: '%s' directive writing up to 1023 bytes into a region 
of size 1012 [-Wformat-overflow=]
  sprintf(path, "pg_replslot/%s/state.tmp", name);
                ^
slot.c:1271:2: note: '__builtin___sprintf_chk' output between 23 and 1046 bytes 
into a destination of size 1024
  sprintf(path, "pg_replslot/%s/state.tmp", name);
  ^
slot.c:1277:16: warning: '%s' directive writing up to 1023 bytes into a region 
of size 1012 [-Wformat-overflow=]
  sprintf(path, "pg_replslot/%s/state", name);
                ^
slot.c:1277:2: note: '__builtin___sprintf_chk' output between 19 and 1042 bytes 
into a destination of size 1024
  sprintf(path, "pg_replslot/%s/state", name);
  ^
slot.c:1388:17: warning: '%s' directive writing up to 1023 bytes into a region 
of size 1012 [-Wformat-overflow=]
   sprintf(path, "pg_replslot/%s", name);
                 ^
slot.c:1388:3: note: '__builtin___sprintf_chk' output between 13 and 1036 bytes 
into a destination of size 1024
   sprintf(path, "pg_replslot/%s", name);
   ^
In file included from /usr/include/stdio.h:498:0,
                 from ../../../../src/include/c.h:81,
                 from ../../../../src/include/postgres.h:47,
                 from fd.c:59:
fd.c: In function 'RemovePgTempFilesInDir':
fd.c:2775:38: warning: '__builtin_snprintf' output may be truncated before the 
last format character [-Wformat-truncation=]
   snprintf(rm_path, sizeof(rm_path), "%s/%s",
                                      ^
fd.c:2775:3: note: '__builtin_snprintf' output 2 or more bytes (assuming 1025) 
into a destination of size 1024
   snprintf(rm_path, sizeof(rm_path), "%s/%s",
   ^
fd.c: In function 'RemovePgTempRelationFiles':
fd.c:2824:48: warning: '__builtin_snprintf' output may be truncated before the 
last format character [-Wformat-truncation=]
   snprintf(dbspace_path, sizeof(dbspace_path), "%s/%s",
                                                ^
fd.c:2824:3: note: '__builtin_snprintf' output 2 or more bytes (assuming 1025) 
into a destination of size 1024
   snprintf(dbspace_path, sizeof(dbspace_path), "%s/%s",
   ^
fd.c:2855:38: warning: '__builtin_snprintf' output may be truncated before the 
last format character [-Wformat-truncation=]
   snprintf(rm_path, sizeof(rm_path), "%s/%s",
                                      ^
fd.c:2855:3: note: '__builtin_snprintf' output 2 or more bytes (assuming 1025) 
into a destination of size 1024
   snprintf(rm_path, sizeof(rm_path), "%s/%s",
   ^
fd.c: In function 'walkdir':
fd.c:3035:32: warning: '__builtin_snprintf' output may be truncated before the 
last format character [-Wformat-truncation=]
   snprintf(subpath, MAXPGPATH, "%s/%s", path, de->d_name);
                                ^
fd.c:3035:3: note: '__builtin_snprintf' output 2 or more bytes (assuming 1025) 
into a destination of size 1024
   snprintf(subpath, MAXPGPATH, "%s/%s", path, de->d_name);
   ^
fd.c: In function 'RemovePgTempFiles':
fd.c:2730:42: warning: '%s' directive output may be truncated writing up to 
1023 bytes into a region of size 1014 [-Wformat-truncation=]
   snprintf(temp_path, sizeof(temp_path), "pg_tblspc/%s/%s/%s",
                                          ^
fd.c:2730:3: note: '__builtin_snprintf' output between 37 and 1060 bytes into a 
destination of size 1024
   snprintf(temp_path, sizeof(temp_path), "pg_tblspc/%s/%s/%s",
   ^
fd.c:2734:42: warning: '%s' directive output may be truncated writing up to 
1023 bytes into a region of size 1014 [-Wformat-truncation=]
   snprintf(temp_path, sizeof(temp_path), "pg_tblspc/%s/%s",
                                          ^
fd.c:2734:3: note: '__builtin_snprintf' output between 27 and 1050 bytes into a 
destination of size 1024
   snprintf(temp_path, sizeof(temp_path), "pg_tblspc/%s/%s",
   ^
In file included from /usr/include/stdio.h:498:0,
                 from ../../../../src/include/c.h:81,
                 from ../../../../src/include/postgres.h:47,
                 from copydir.c:19:
copydir.c: In function 'copydir':
copydir.c:66:33: warning: '__builtin_snprintf' output may be truncated before 
the last format character [-Wformat-truncation=]
   snprintf(fromfile, MAXPGPATH, "%s/%s", fromdir, xlde->d_name);
                                 ^
copydir.c:66:3: note: '__builtin_snprintf' output 2 or more bytes (assuming 
1025) into a destination of size 1024
   snprintf(fromfile, MAXPGPATH, "%s/%s", fromdir, xlde->d_name);
   ^
copydir.c:67:31: warning: '__builtin_snprintf' output may be truncated before 
the last format character [-Wformat-truncation=]
   snprintf(tofile, MAXPGPATH, "%s/%s", todir, xlde->d_name);
                               ^
copydir.c:67:3: note: '__builtin_snprintf' output 2 or more bytes (assuming 
1025) into a destination of size 1024
   snprintf(tofile, MAXPGPATH, "%s/%s", todir, xlde->d_name);
   ^
copydir.c:106:31: warning: '__builtin_snprintf' output may be truncated before 
the last format character [-Wformat-truncation=]
   snprintf(tofile, MAXPGPATH, "%s/%s", todir, xlde->d_name);
                               ^
copydir.c:106:3: note: '__builtin_snprintf' output 2 or more bytes (assuming 
1025) into a destination of size 1024
   snprintf(tofile, MAXPGPATH, "%s/%s", todir, xlde->d_name);
   ^
In file included from /usr/include/stdio.h:498:0,
                 from ../../../../src/include/c.h:81,
                 from ../../../../src/include/postgres.h:47,
                 from reinit.c:15:
reinit.c: In function 'ResetUnloggedRelationsInTablespaceDir':
reinit.c:134:48: warning: '__builtin_snprintf' output may be truncated before 
the last format character [-Wformat-truncation=]
   snprintf(dbspace_path, sizeof(dbspace_path), "%s/%s",
                                                ^
reinit.c:134:3: note: '__builtin_snprintf' output 2 or more bytes (assuming 
1025) into a destination of size 1024
   snprintf(dbspace_path, sizeof(dbspace_path), "%s/%s",
   ^
reinit.c:264:40: warning: '__builtin_snprintf' output may be truncated before 
the last format character [-Wformat-truncation=]
     snprintf(rm_path, sizeof(rm_path), "%s/%s",
                                        ^
reinit.c:264:5: note: '__builtin_snprintf' output 2 or more bytes (assuming 
1025) into a destination of size 1024
     snprintf(rm_path, sizeof(rm_path), "%s/%s",
     ^
reinit.c:324:39: warning: '__builtin_snprintf' output may be truncated before 
the last format character [-Wformat-truncation=]
    snprintf(srcpath, sizeof(srcpath), "%s/%s",
                                       ^
reinit.c:324:4: note: '__builtin_snprintf' output 2 or more bytes (assuming 
1025) into a destination of size 1024
    snprintf(srcpath, sizeof(srcpath), "%s/%s",
    ^
reinit.c: In function 'ResetUnloggedRelations':
reinit.c:87:42: warning: '%s' directive output may be truncated writing up to 
1023 bytes into a region of size 1014 [-Wformat-truncation=]
   snprintf(temp_path, sizeof(temp_path), "pg_tblspc/%s/%s",
                                          ^
reinit.c:87:3: note: '__builtin_snprintf' output between 27 and 1050 bytes into 
a destination of size 1024
   snprintf(temp_path, sizeof(temp_path), "pg_tblspc/%s/%s",
   ^
In file included from /usr/include/stdio.h:498:0,
                 from ../../../../src/include/c.h:81,
                 from ../../../../src/include/postgres.h:47,
                 from dsm.c:27:
dsm.c: In function 'dsm_cleanup_for_mmap':
../../../../src/include/storage/dsm_impl.h:51:29: warning: '%s' directive 
output may be truncated writing up to 1023 bytes into a region of size 1012 
[-Wformat-truncation=]
 #define PG_DYNSHMEM_DIR     "pg_dynshmem"
                             ^
dsm.c:312:29: note: in expansion of macro 'PG_DYNSHMEM_DIR'
    snprintf(buf, MAXPGPATH, PG_DYNSHMEM_DIR "/%s", dent->d_name);
                             ^~~~~~~~~~~~~~~
dsm.c:312:47: note: format string is defined here
    snprintf(buf, MAXPGPATH, PG_DYNSHMEM_DIR "/%s", dent->d_name);
                                               ^~
In file included from /usr/include/stdio.h:498:0,
                 from ../../../../src/include/c.h:81,
                 from ../../../../src/include/postgres.h:47,
                 from dsm.c:27:
dsm.c:312:4: note: '__builtin_snprintf' output between 13 and 1036 bytes into a 
destination of size 1024
    snprintf(buf, MAXPGPATH, PG_DYNSHMEM_DIR "/%s", dent->d_name);
    ^
In file included from /usr/include/stdio.h:498:0,
                 from ../../../../src/include/c.h:81,
                 from ../../../../src/include/postgres.h:47,
                 from dbsize.c:12:
dbsize.c: In function 'db_dir_size':
dbsize.c:61:33: warning: '__builtin_snprintf' output may be truncated before 
the last format character [-Wformat-truncation=]
   snprintf(filename, MAXPGPATH, "%s/%s", path, direntry->d_name);
                                 ^
dbsize.c:61:3: note: '__builtin_snprintf' output 2 or more bytes (assuming 
1025) into a destination of size 1024
   snprintf(filename, MAXPGPATH, "%s/%s", path, direntry->d_name);
   ^
dbsize.c: In function 'calculate_database_size':
dbsize.c:127:33: warning: '%s' directive output may be truncated writing up to 
1023 bytes into a region of size 1014 [-Wformat-truncation=]
   snprintf(pathname, MAXPGPATH, "pg_tblspc/%s/%s/%u",
                                 ^
dbsize.c:127:3: note: '__builtin_snprintf' output between 29 and 1061 bytes 
into a destination of size 1024
   snprintf(pathname, MAXPGPATH, "pg_tblspc/%s/%s/%u",
   ^
dbsize.c: In function 'calculate_tablespace_size':
dbsize.c:218:33: warning: '__builtin_snprintf' output may be truncated before 
the last format character [-Wformat-truncation=]
   snprintf(pathname, MAXPGPATH, "%s/%s", tblspcPath, direntry->d_name);
                                 ^
dbsize.c:218:3: note: '__builtin_snprintf' output 2 or more bytes (assuming 
1025) into a destination of size 1024
   snprintf(pathname, MAXPGPATH, "%s/%s", tblspcPath, direntry->d_name);
   ^
In file included from /usr/include/stdio.h:498:0,
                 from ../../../../src/include/c.h:81,
                 from ../../../../src/include/postgres.h:47,
                 from genfile.c:16:
genfile.c: In function 'pg_ls_dir_files':
genfile.c:534:29: warning: '__builtin_snprintf' output may be truncated before 
the last format character [-Wformat-truncation=]
   snprintf(path, MAXPGPATH, "%s/%s", fctx->location, de->d_name);
                             ^
genfile.c:534:3: note: '__builtin_snprintf' output 2 or more bytes (assuming 
1025) into a destination of size 1024
   snprintf(path, MAXPGPATH, "%s/%s", fctx->location, de->d_name);
   ^
In file included from /usr/include/stdio.h:498:0,
                 from ../../../../src/include/c.h:81,
                 from ../../../../src/include/postgres.h:47,
                 from relcache.c:27:
relcache.c: In function 'RelationCacheInitFileRemoveInDir':
relcache.c:6135:49: warning: '/' directive output may be truncated writing 1 
byte into a region of size between 0 and 1023 [-Wformat-truncation=]
    snprintf(initfilename, sizeof(initfilename), "%s/%s/%s",
                                                 ^
relcache.c:6135:4: note: '__builtin_snprintf' output 19 or more bytes (assuming 
1042) into a destination of size 1024
    snprintf(initfilename, sizeof(initfilename), "%s/%s/%s",
    ^
relcache.c: In function 'RelationCacheInitFileRemove':
relcache.c:6104:33: warning: '%s' directive output may be truncated writing up 
to 1023 bytes into a region of size 1014 [-Wformat-truncation=]
    snprintf(path, sizeof(path), "%s/%s/%s",
                                 ^
relcache.c:6104:4: note: '__builtin_snprintf' output between 27 and 1050 bytes 
into a destination of size 1024
    snprintf(path, sizeof(path), "%s/%s/%s",
    ^
In file included from /usr/include/stdio.h:498:0,
                 from ../../../../src/include/c.h:81,
                 from ../../../../src/include/postgres.h:47,
                 from elog.c:55:
elog.c: In function 'setup_formatted_log_time':
elog.c:2252:17: warning: '%03d' directive writing between 3 and 8 bytes into a 
region of size 7 [-Wformat-overflow=]
  sprintf(msbuf, ".%03d", (int) (saved_timeval.tv_usec / 1000));
                 ^
elog.c:2252:17: note: directive argument in the range [-2147483, 2147483]
elog.c:2252:2: note: '__builtin___sprintf_chk' output between 5 and 10 bytes 
into a destination of size 8
  sprintf(msbuf, ".%03d", (int) (saved_timeval.tv_usec / 1000));
  ^
In file included from /usr/include/stdio.h:498:0,
                 from ../../../../src/include/c.h:81,
                 from ../../../../src/include/postgres.h:47,
                 from snapmgr.c:46:
snapmgr.c: In function 'DeleteAllExportedSnapshotFiles':
snapmgr.c:213:29: warning: '%s' directive output may be truncated writing up to 
1023 bytes into a region of size 1011 [-Wformat-truncation=]
 #define SNAPSHOT_EXPORT_DIR "pg_snapshots"
                             ^
snapmgr.c:1602:28: note: in expansion of macro 'SNAPSHOT_EXPORT_DIR'
   snprintf(buf, MAXPGPATH, SNAPSHOT_EXPORT_DIR "/%s", s_de->d_name);
                            ^~~~~~~~~~~~~~~~~~~
snapmgr.c:1602:50: note: format string is defined here
   snprintf(buf, MAXPGPATH, SNAPSHOT_EXPORT_DIR "/%s", s_de->d_name);
                                                  ^~
In file included from /usr/include/stdio.h:498:0,
                 from ../../../../src/include/c.h:81,
                 from ../../../../src/include/postgres.h:47,
                 from snapmgr.c:46:
snapmgr.c:1602:3: note: '__builtin_snprintf' output between 14 and 1037 bytes 
into a destination of size 1024
   snprintf(buf, MAXPGPATH, SNAPSHOT_EXPORT_DIR "/%s", s_de->d_name);
   ^
In file included from /usr/include/stdio.h:498:0,
                 from ../../../src/include/c.h:81,
                 from ../../../src/include/postgres_fe.h:25,
                 from pg_archivecleanup.c:13:
pg_archivecleanup.c: In function 'CleanupPriorWALFiles':
pg_archivecleanup.c:136:38: warning: '__builtin_snprintf' output may be 
truncated before the last format character [-Wformat-truncation=]
     snprintf(WALFilePath, MAXPGPATH, "%s/%s",
                                      ^
pg_archivecleanup.c:136:5: note: '__builtin_snprintf' output 2 or more bytes 
(assuming 1025) into a destination of size 1024
     snprintf(WALFilePath, MAXPGPATH, "%s/%s",
     ^
In file included from /usr/include/stdio.h:498:0,
                 from ../../../src/include/c.h:81,
                 from ../../../src/include/postgres_fe.h:25,
                 from pg_receivewal.c:15:
pg_receivewal.c: In function 'FindStreamingStart':
pg_receivewal.c:272:41: warning: '__builtin_snprintf' output may be truncated 
before the last format character [-Wformat-truncation=]
    snprintf(fullpath, sizeof(fullpath), "%s/%s", basedir, dirent->d_name);
                                         ^
pg_receivewal.c:272:4: note: '__builtin_snprintf' output 2 or more bytes 
(assuming 1025) into a destination of size 1024
    snprintf(fullpath, sizeof(fullpath), "%s/%s", basedir, dirent->d_name);
    ^
pg_receivewal.c:249:41: warning: '__builtin_snprintf' output may be truncated 
before the last format character [-Wformat-truncation=]
    snprintf(fullpath, sizeof(fullpath), "%s/%s", basedir, dirent->d_name);
                                         ^
pg_receivewal.c:249:4: note: '__builtin_snprintf' output 2 or more bytes 
(assuming 1025) into a destination of size 1024
    snprintf(fullpath, sizeof(fullpath), "%s/%s", basedir, dirent->d_name);
    ^
In file included from /usr/include/stdio.h:498:0,
                 from ../../../src/include/c.h:81,
                 from ../../../src/include/postgres.h:47,
                 from pg_resetwal.c:38:
pg_resetwal.c: In function 'KillExistingXLOG':
pg_resetwal.c:976:30: warning: '%s' directive output may be truncated writing 
up to 1023 bytes into a region of size 1017 [-Wformat-truncation=]
    snprintf(path, MAXPGPATH, "%s/%s", XLOGDIR, xlde->d_name);
                              ^
pg_resetwal.c:976:4: note: '__builtin_snprintf' output between 8 and 1031 bytes 
into a destination of size 1024
    snprintf(path, MAXPGPATH, "%s/%s", XLOGDIR, xlde->d_name);
    ^
pg_resetwal.c: In function 'KillExistingArchiveStatus':
pg_resetwal.c:1030:30: warning: '%s' directive output may be truncated writing 
up to 1023 bytes into a region of size 1002 [-Wformat-truncation=]
    snprintf(path, MAXPGPATH, "%s/%s", ARCHSTATDIR, xlde->d_name);
                              ^
pg_resetwal.c:1030:4: note: '__builtin_snprintf' output between 23 and 1046 
bytes into a destination of size 1024
    snprintf(path, MAXPGPATH, "%s/%s", ARCHSTATDIR, xlde->d_name);
    ^
In file included from /usr/include/stdio.h:498:0,
                 from ../../../src/include/c.h:81,
                 from ../../../src/include/postgres_fe.h:25,
                 from copy_fetch.c:10:
copy_fetch.c: In function 'recurse_dir':
copy_fetch.c:75:33: warning: '__builtin_snprintf' output may be truncated 
before the last format character [-Wformat-truncation=]
   snprintf(fullpath, MAXPGPATH, "%s/%s", fullparentpath, xlde->d_name);
                                 ^
copy_fetch.c:75:3: note: '__builtin_snprintf' output 2 or more bytes (assuming 
1025) into a destination of size 1024
   snprintf(fullpath, MAXPGPATH, "%s/%s", fullparentpath, xlde->d_name);
   ^
copy_fetch.c:96:30: warning: '__builtin_snprintf' output may be truncated 
before the last format character [-Wformat-truncation=]
    snprintf(path, MAXPGPATH, "%s/%s", parentpath, xlde->d_name);
                              ^
copy_fetch.c:96:4: note: '__builtin_snprintf' output 2 or more bytes (assuming 
1025) into a destination of size 1024
    snprintf(path, MAXPGPATH, "%s/%s", parentpath, xlde->d_name);
    ^
In file included from /usr/include/stdio.h:498:0,
                 from ../../src/include/c.h:81,
                 from ../../src/include/postgres_fe.h:25,
                 from pg_standby.c:24:
pg_standby.c: In function 'main':
pg_standby.c:264:39: warning: '__builtin_snprintf' output may be truncated 
before the last format character [-Wformat-truncation=]
      snprintf(WALFilePath, MAXPGPATH, "%s/%s", archiveLocation, xlde->d_name);
                                       ^
pg_standby.c:264:6: note: '__builtin_snprintf' output 2 or more bytes (assuming 
1025) into a destination of size 1024
      snprintf(WALFilePath, MAXPGPATH, "%s/%s", archiveLocation, xlde->d_name);
      ^

Attachment: 0001-Fix-various-new-warnings-from-gcc-7.patch
Description: invalid/octet-stream

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to