]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Fix new warnings from GCC 7
authorPeter Eisentraut <peter_e@gmx.net>
Tue, 11 Apr 2017 18:13:31 +0000 (14:13 -0400)
committerPeter Eisentraut <peter_e@gmx.net>
Mon, 15 May 2017 17:31:42 +0000 (13:31 -0400)
This addresses the new warning types -Wformat-truncation
-Wformat-overflow that are part of -Wall, via -Wformat, in GCC 7.

21 files changed:
contrib/pg_archivecleanup/pg_archivecleanup.c
contrib/pg_standby/pg_standby.c
src/backend/access/heap/rewriteheap.c
src/backend/access/transam/xlog.c
src/backend/postmaster/pgstat.c
src/backend/replication/basebackup.c
src/backend/replication/logical/reorderbuffer.c
src/backend/replication/logical/snapbuild.c
src/backend/replication/slot.c
src/backend/storage/file/copydir.c
src/backend/storage/file/fd.c
src/backend/storage/file/reinit.c
src/backend/storage/ipc/dsm.c
src/backend/utils/adt/dbsize.c
src/backend/utils/cache/relcache.c
src/backend/utils/error/elog.c
src/backend/utils/time/snapmgr.c
src/bin/initdb/initdb.c
src/bin/pg_basebackup/pg_receivexlog.c
src/bin/pg_resetxlog/pg_resetxlog.c
src/timezone/pgtz.c

index 212b267fcfa6cdd4b406570e325c54effcf704bc..9f97153ca0f0bbfedcd9ce3cf26ea25d51018bb1 100644 (file)
@@ -30,7 +30,7 @@ char     *additional_ext = NULL;              /* Extension to remove from filenames */
 
 char      *archiveLocation;    /* where to find the archive? */
 char      *restartWALFileName; /* the file from which we can restart restore */
-char           WALFilePath[MAXPGPATH];         /* the file path including archive */
+char           WALFilePath[MAXPGPATH * 2];             /* the file path including archive */
 char           exclusiveCleanupFileName[MAXPGPATH];            /* the oldest file we
                                                                                                                 * want to remain in
                                                                                                                 * archive */
@@ -133,7 +133,7 @@ CleanupPriorWALFiles(void)
                                 * extension that might have been chopped off before testing
                                 * the sequence.
                                 */
-                               snprintf(WALFilePath, MAXPGPATH, "%s/%s",
+                               snprintf(WALFilePath, sizeof(WALFilePath), "%s/%s",
                                                 archiveLocation, xlde->d_name);
 
                                if (dryrun)
index 716c7dd9bdb3a523baacc5887e2821f0b27a98f8..80ab599b977807f2de36ca1593c7b27f81379997 100644 (file)
@@ -55,7 +55,7 @@ char     *xlogFilePath;               /* where we are going to restore to */
 char      *nextWALFileName;    /* the file we need to get from archive */
 char      *restartWALFileName; /* the file from which we can restart restore */
 char      *priorWALFileName;   /* the file we need to get from archive */
-char           WALFilePath[MAXPGPATH];         /* the file path including archive */
+char           WALFilePath[MAXPGPATH * 2];             /* the file path including archive */
 char           restoreCommand[MAXPGPATH];      /* run this to restore */
 char           exclusiveCleanupFileName[MAXPGPATH];            /* the file we need to
                                                                                                                 * get from archive */
@@ -266,9 +266,9 @@ CustomizableCleanupPriorWALFiles(void)
                                  strcmp(xlde->d_name + 8, exclusiveCleanupFileName + 8) < 0)
                                {
 #ifdef WIN32
-                                       snprintf(WALFilePath, MAXPGPATH, "%s\\%s", archiveLocation, xlde->d_name);
+                                       snprintf(WALFilePath, sizeof(WALFilePath), "%s\\%s", archiveLocation, xlde->d_name);
 #else
-                                       snprintf(WALFilePath, MAXPGPATH, "%s/%s", archiveLocation, xlde->d_name);
+                                       snprintf(WALFilePath, sizeof(WALFilePath), "%s/%s", archiveLocation, xlde->d_name);
 #endif
 
                                        if (debug)
index 158c6c034392ceffd441137ac05c21828b5468b7..07f08a4d89f5ef7f5630d1e6666ac70417b5b6c6 100644 (file)
@@ -1204,7 +1204,7 @@ CheckPointLogicalRewriteHeap(void)
        XLogRecPtr      redo;
        DIR                *mappings_dir;
        struct dirent *mapping_de;
-       char            path[MAXPGPATH];
+       char            path[MAXPGPATH + 20];
 
        /*
         * We start of with a minimum of the last redo pointer. No new decoding
@@ -1235,7 +1235,7 @@ CheckPointLogicalRewriteHeap(void)
                        strcmp(mapping_de->d_name, "..") == 0)
                        continue;
 
-               snprintf(path, MAXPGPATH, "pg_logical/mappings/%s", mapping_de->d_name);
+               snprintf(path, sizeof(path), "pg_logical/mappings/%s", mapping_de->d_name);
                if (lstat(path, &statbuf) == 0 && !S_ISREG(statbuf.st_mode))
                        continue;
 
index d8f3d5c5170e4c97240e75bc8fa1a46fb017c708..17a26926599be39e794520fe29add06143900ebb 100644 (file)
@@ -3987,7 +3987,7 @@ CleanupBackupHistory(void)
 {
        DIR                *xldir;
        struct dirent *xlde;
-       char            path[MAXPGPATH];
+       char            path[MAXPGPATH + sizeof(XLOGDIR)];
 
        xldir = AllocateDir(XLOGDIR);
        if (xldir == NULL)
@@ -4008,7 +4008,7 @@ CleanupBackupHistory(void)
                                ereport(DEBUG2,
                                (errmsg("removing transaction log backup history file \"%s\"",
                                                xlde->d_name)));
-                               snprintf(path, MAXPGPATH, XLOGDIR "/%s", xlde->d_name);
+                               snprintf(path, sizeof(path), XLOGDIR "/%s", xlde->d_name);
                                unlink(path);
                                XLogArchiveCleanup(xlde->d_name);
                        }
index 085b94acfe7c786ac24d7944e69f27d68107087f..e4cc0dc35214d75968820d359550678227935183 100644 (file)
@@ -567,7 +567,7 @@ pgstat_reset_remove_files(const char *directory)
 {
        DIR                *dir;
        struct dirent *entry;
-       char            fname[MAXPGPATH];
+       char            fname[MAXPGPATH * 2];
 
        dir = AllocateDir(directory);
        while ((entry = ReadDir(dir, directory)) != NULL)
@@ -597,7 +597,7 @@ pgstat_reset_remove_files(const char *directory)
                        strcmp(entry->d_name + nchars, "stat") != 0)
                        continue;
 
-               snprintf(fname, MAXPGPATH, "%s/%s", directory,
+               snprintf(fname, sizeof(fname), "%s/%s", directory,
                                 entry->d_name);
                unlink(fname);
        }
index bcb5eff620bef641f988e71a3843f78f45c8eac2..e4074d3035123acd6ddbb9600feceb7cf25db176 100644 (file)
@@ -167,7 +167,7 @@ perform_base_backup(basebackup_options *opt, DIR *tblspcdir)
                /* Collect information about all tablespaces */
                while ((de = ReadDir(tblspcdir, "pg_tblspc")) != NULL)
                {
-                       char            fullpath[MAXPGPATH];
+                       char            fullpath[MAXPGPATH + 10];
                        char            linkpath[MAXPGPATH];
                        char       *relpath = NULL;
                        int                     rllen;
@@ -930,7 +930,7 @@ sendDir(char *path, int basepathlen, bool sizeonly, List *tablespaces)
 {
        DIR                *dir;
        struct dirent *de;
-       char            pathbuf[MAXPGPATH];
+       char            pathbuf[MAXPGPATH * 2];
        struct stat statbuf;
        int64           size = 0;
 
@@ -978,7 +978,7 @@ sendDir(char *path, int basepathlen, bool sizeonly, List *tablespaces)
                                                 "and should not be used. "
                                                 "Try taking another online backup.")));
 
-               snprintf(pathbuf, MAXPGPATH, "%s/%s", path, de->d_name);
+               snprintf(pathbuf, sizeof(pathbuf), "%s/%s", path, de->d_name);
 
                /* Skip postmaster.pid and postmaster.opts in the data directory */
                if (strcmp(pathbuf, "./postmaster.pid") == 0 ||
index e5c3625abf52cd4bd6d4927204025cb7a0fbf7ed..56490689701b8cb71908f8c0a23b2a860b092a5d 100644 (file)
@@ -2443,7 +2443,7 @@ StartupReorderBuffer(void)
        while ((logical_de = ReadDir(logical_dir, "pg_replslot")) != NULL)
        {
                struct stat statbuf;
-               char            path[MAXPGPATH];
+               char            path[MAXPGPATH * 2 + 12];
 
                if (strcmp(logical_de->d_name, ".") == 0 ||
                        strcmp(logical_de->d_name, "..") == 0)
index b08afe6694a8e0fff19277b3c8590656ed1668c9..9359fc2386db4dedab37508a228e9ea0c3bf0dcf 100644 (file)
@@ -1814,7 +1814,7 @@ CheckPointSnapBuild(void)
        XLogRecPtr      redo;
        DIR                *snap_dir;
        struct dirent *snap_de;
-       char            path[MAXPGPATH];
+       char            path[MAXPGPATH + 21];
 
        /*
         * We start of with a minimum of the last redo pointer. No new replication
@@ -1841,7 +1841,7 @@ CheckPointSnapBuild(void)
                        strcmp(snap_de->d_name, "..") == 0)
                        continue;
 
-               snprintf(path, MAXPGPATH, "pg_logical/snapshots/%s", snap_de->d_name);
+               snprintf(path, sizeof(path), "pg_logical/snapshots/%s", snap_de->d_name);
 
                if (lstat(path, &statbuf) == 0 && !S_ISREG(statbuf.st_mode))
                {
index f108979e6f1beb93b4bca7fb7c70d98916f9ffe8..7f04b22d2d6e69eae67c7de2679100c5e4c3b0b0 100644 (file)
@@ -860,13 +860,13 @@ StartupReplicationSlots(void)
        while ((replication_de = ReadDir(replication_dir, "pg_replslot")) != NULL)
        {
                struct stat statbuf;
-               char            path[MAXPGPATH];
+               char            path[MAXPGPATH + 12];
 
                if (strcmp(replication_de->d_name, ".") == 0 ||
                        strcmp(replication_de->d_name, "..") == 0)
                        continue;
 
-               snprintf(path, MAXPGPATH, "pg_replslot/%s", replication_de->d_name);
+               snprintf(path, sizeof(path), "pg_replslot/%s", replication_de->d_name);
 
                /* we're only creating directories here, skip if it's not our's */
                if (lstat(path, &statbuf) == 0 && !S_ISDIR(statbuf.st_mode))
@@ -1098,7 +1098,7 @@ RestoreSlotFromDisk(const char *name)
 {
        ReplicationSlotOnDisk cp;
        int                     i;
-       char            path[MAXPGPATH];
+       char            path[MAXPGPATH + 22];
        int                     fd;
        bool            restored = false;
        int                     readBytes;
index e17b8947ef76ab37ddc47b10e78205e78a4598af..48d5dee797b5296f5d71fa8e9f75cf6c4f1a192f 100644 (file)
@@ -38,8 +38,8 @@ copydir(char *fromdir, char *todir, bool recurse)
 {
        DIR                *xldir;
        struct dirent *xlde;
-       char            fromfile[MAXPGPATH];
-       char            tofile[MAXPGPATH];
+       char            fromfile[MAXPGPATH * 2];
+       char            tofile[MAXPGPATH * 2];
 
        if (mkdir(todir, S_IRWXU) != 0)
                ereport(ERROR,
@@ -63,8 +63,8 @@ copydir(char *fromdir, char *todir, bool recurse)
                        strcmp(xlde->d_name, "..") == 0)
                        continue;
 
-               snprintf(fromfile, MAXPGPATH, "%s/%s", fromdir, xlde->d_name);
-               snprintf(tofile, MAXPGPATH, "%s/%s", todir, xlde->d_name);
+               snprintf(fromfile, sizeof(fromfile), "%s/%s", fromdir, xlde->d_name);
+               snprintf(tofile, sizeof(tofile), "%s/%s", todir, xlde->d_name);
 
                if (lstat(fromfile, &fst) < 0)
                        ereport(ERROR,
@@ -103,7 +103,7 @@ copydir(char *fromdir, char *todir, bool recurse)
                        strcmp(xlde->d_name, "..") == 0)
                        continue;
 
-               snprintf(tofile, MAXPGPATH, "%s/%s", todir, xlde->d_name);
+               snprintf(tofile, sizeof(tofile), "%s/%s", todir, xlde->d_name);
 
                /*
                 * We don't need to sync subdirectories here since the recursive
index ca1661b08ad3a20e49f9263e8f4ccf37ede96124..845023590eab9e708ca82d342de6d0d8f5ddfa0f 100644 (file)
@@ -2453,7 +2453,7 @@ CleanupTempFiles(bool isProcExit)
 void
 RemovePgTempFiles(void)
 {
-       char            temp_path[MAXPGPATH];
+       char            temp_path[MAXPGPATH + 10 + sizeof(TABLESPACE_VERSION_DIRECTORY) + sizeof(PG_TEMP_FILES_DIR)];
        DIR                *spc_dir;
        struct dirent *spc_de;
 
@@ -2501,7 +2501,7 @@ RemovePgTempFilesInDir(const char *tmpdirname)
 {
        DIR                *temp_dir;
        struct dirent *temp_de;
-       char            rm_path[MAXPGPATH];
+       char            rm_path[MAXPGPATH * 2];
 
        temp_dir = AllocateDir(tmpdirname);
        if (temp_dir == NULL)
@@ -2542,7 +2542,7 @@ RemovePgTempRelationFiles(const char *tsdirname)
 {
        DIR                *ts_dir;
        struct dirent *de;
-       char            dbspace_path[MAXPGPATH];
+       char            dbspace_path[MAXPGPATH * 2];
 
        ts_dir = AllocateDir(tsdirname);
        if (ts_dir == NULL)
@@ -2583,7 +2583,7 @@ RemovePgTempRelationFilesInDbspace(const char *dbspacedirname)
 {
        DIR                *dbspace_dir;
        struct dirent *de;
-       char            rm_path[MAXPGPATH];
+       char            rm_path[MAXPGPATH * 2];
 
        dbspace_dir = AllocateDir(dbspacedirname);
        if (dbspace_dir == NULL)
@@ -2770,7 +2770,7 @@ walkdir(const char *path,
 
        while ((de = ReadDirExtended(dir, path, elevel)) != NULL)
        {
-               char            subpath[MAXPGPATH];
+               char            subpath[MAXPGPATH * 2];
                struct stat fst;
                int                     sret;
 
@@ -2780,7 +2780,7 @@ walkdir(const char *path,
                        strcmp(de->d_name, "..") == 0)
                        continue;
 
-               snprintf(subpath, MAXPGPATH, "%s/%s", path, de->d_name);
+               snprintf(subpath, sizeof(subpath), "%s/%s", path, de->d_name);
 
                if (process_symlinks)
                        sret = stat(subpath, &fst);
index fe10c56926feacc77d852c3ec22401b40ef955e2..65bd9a93427e27f62ee238617ce5a07abf5c6647 100644 (file)
@@ -48,7 +48,7 @@ typedef struct
 void
 ResetUnloggedRelations(int op)
 {
-       char            temp_path[MAXPGPATH];
+       char            temp_path[MAXPGPATH + 10 + sizeof(TABLESPACE_VERSION_DIRECTORY)];
        DIR                *spc_dir;
        struct dirent *spc_de;
        MemoryContext tmpctx,
@@ -106,7 +106,7 @@ ResetUnloggedRelationsInTablespaceDir(const char *tsdirname, int op)
 {
        DIR                *ts_dir;
        struct dirent *de;
-       char            dbspace_path[MAXPGPATH];
+       char            dbspace_path[MAXPGPATH * 2];
 
        ts_dir = AllocateDir(tsdirname);
        if (ts_dir == NULL)
@@ -147,7 +147,7 @@ ResetUnloggedRelationsInDbspaceDir(const char *dbspacedirname, int op)
 {
        DIR                *dbspace_dir;
        struct dirent *de;
-       char            rm_path[MAXPGPATH];
+       char            rm_path[MAXPGPATH * 2];
 
        /* Caller must specify at least one operation. */
        Assert((op & (UNLOGGED_RELATION_CLEANUP | UNLOGGED_RELATION_INIT)) != 0);
@@ -310,7 +310,7 @@ ResetUnloggedRelationsInDbspaceDir(const char *dbspacedirname, int op)
                        ForkNumber      forkNum;
                        int                     oidchars;
                        char            oidbuf[OIDCHARS + 1];
-                       char            srcpath[MAXPGPATH];
+                       char            srcpath[MAXPGPATH * 2];
                        char            dstpath[MAXPGPATH];
 
                        /* Skip anything that doesn't look like a relation data file. */
index 7ce45caaf9b0986cf7df794674e2f9cb4a40e00c..43e68a61846cecff62ec8e0866292aa8a987e3f0 100644 (file)
@@ -306,9 +306,9 @@ dsm_cleanup_for_mmap(void)
                if (strncmp(dent->d_name, PG_DYNSHMEM_MMAP_FILE_PREFIX,
                                        strlen(PG_DYNSHMEM_MMAP_FILE_PREFIX)) == 0)
                {
-                       char            buf[MAXPGPATH];
+                       char            buf[MAXPGPATH + sizeof(PG_DYNSHMEM_DIR)];
 
-                       snprintf(buf, MAXPGPATH, PG_DYNSHMEM_DIR "/%s", dent->d_name);
+                       snprintf(buf, sizeof(buf), PG_DYNSHMEM_DIR "/%s", dent->d_name);
 
                        elog(DEBUG2, "removing file \"%s\"", buf);
 
index 8c663379ae7e854b59589e69e81bad0423cae0c4..93dea1d9cf52bc073ee7b0260504bd1f7697e45c 100644 (file)
@@ -39,7 +39,7 @@ db_dir_size(const char *path)
        int64           dirsize = 0;
        struct dirent *direntry;
        DIR                *dirdesc;
-       char            filename[MAXPGPATH];
+       char            filename[MAXPGPATH * 2];
 
        dirdesc = AllocateDir(path);
 
@@ -56,7 +56,7 @@ db_dir_size(const char *path)
                        strcmp(direntry->d_name, "..") == 0)
                        continue;
 
-               snprintf(filename, MAXPGPATH, "%s/%s", path, direntry->d_name);
+               snprintf(filename, sizeof(filename), "%s/%s", path, direntry->d_name);
 
                if (stat(filename, &fst) < 0)
                {
@@ -84,7 +84,7 @@ calculate_database_size(Oid dbOid)
        DIR                *dirdesc;
        struct dirent *direntry;
        char            dirpath[MAXPGPATH];
-       char            pathname[MAXPGPATH];
+       char            pathname[MAXPGPATH + 12 + sizeof(TABLESPACE_VERSION_DIRECTORY)];
        AclResult       aclresult;
 
        /* User must have connect privilege for target database */
@@ -96,7 +96,7 @@ calculate_database_size(Oid dbOid)
        /* Shared storage in pg_global is not counted */
 
        /* Include pg_default storage */
-       snprintf(pathname, MAXPGPATH, "base/%u", dbOid);
+       snprintf(pathname, sizeof(pathname), "base/%u", dbOid);
        totalsize = db_dir_size(pathname);
 
        /* Scan the non-default tablespaces */
@@ -116,7 +116,7 @@ calculate_database_size(Oid dbOid)
                        strcmp(direntry->d_name, "..") == 0)
                        continue;
 
-               snprintf(pathname, MAXPGPATH, "pg_tblspc/%s/%s/%u",
+               snprintf(pathname, sizeof(pathname), "pg_tblspc/%s/%s/%u",
                                 direntry->d_name, TABLESPACE_VERSION_DIRECTORY, dbOid);
                totalsize += db_dir_size(pathname);
        }
@@ -164,7 +164,7 @@ static int64
 calculate_tablespace_size(Oid tblspcOid)
 {
        char            tblspcPath[MAXPGPATH];
-       char            pathname[MAXPGPATH];
+       char            pathname[MAXPGPATH * 2];
        int64           totalsize = 0;
        DIR                *dirdesc;
        struct dirent *direntry;
@@ -206,7 +206,7 @@ calculate_tablespace_size(Oid tblspcOid)
                        strcmp(direntry->d_name, "..") == 0)
                        continue;
 
-               snprintf(pathname, MAXPGPATH, "%s/%s", tblspcPath, direntry->d_name);
+               snprintf(pathname, sizeof(pathname), "%s/%s", tblspcPath, direntry->d_name);
 
                if (stat(pathname, &fst) < 0)
                {
index 6fe3b9b8219bdfffbb8732bfed726a9dd4dfd029..6b9494bda9001c3547214236f4493ba133581804 100644 (file)
@@ -5160,7 +5160,7 @@ RelationCacheInitFileRemove(void)
        const char *tblspcdir = "pg_tblspc";
        DIR                *dir;
        struct dirent *de;
-       char            path[MAXPGPATH];
+       char            path[MAXPGPATH + 10 + sizeof(TABLESPACE_VERSION_DIRECTORY)];
 
        /*
         * We zap the shared cache file too.  In theory it can't get out of sync
@@ -5202,7 +5202,7 @@ RelationCacheInitFileRemoveInDir(const char *tblspcpath)
 {
        DIR                *dir;
        struct dirent *de;
-       char            initfilename[MAXPGPATH];
+       char            initfilename[MAXPGPATH * 2];
 
        /* Scan the tablespace directory to find per-database directories */
        dir = AllocateDir(tblspcpath);
index de46945e6854773c8918bbb1084cc50b52d9e5e5..47a3dffdcf52a217d2572a065840993cd198cdf5 100644 (file)
@@ -2153,7 +2153,7 @@ setup_formatted_log_time(void)
 {
        struct timeval tv;
        pg_time_t       stamp_time;
-       char            msbuf[8];
+       char            msbuf[13];
 
        gettimeofday(&tv, NULL);
        stamp_time = (pg_time_t) tv.tv_sec;
index 674cce2f7811eb7b6994a5ea566d165ca1aea724..a70605b03753996d0b70becbef815592fe456cae 100644 (file)
@@ -1313,7 +1313,7 @@ XactHasExportedSnapshots(void)
 void
 DeleteAllExportedSnapshotFiles(void)
 {
-       char            buf[MAXPGPATH];
+       char            buf[MAXPGPATH + sizeof(SNAPSHOT_EXPORT_DIR)];
        DIR                *s_dir;
        struct dirent *s_de;
 
@@ -1334,7 +1334,7 @@ DeleteAllExportedSnapshotFiles(void)
                        strcmp(s_de->d_name, "..") == 0)
                        continue;
 
-               snprintf(buf, MAXPGPATH, SNAPSHOT_EXPORT_DIR "/%s", s_de->d_name);
+               snprintf(buf, sizeof(buf), SNAPSHOT_EXPORT_DIR "/%s", s_de->d_name);
                /* Again, unlink failure is not worthy of FATAL */
                if (unlink(buf))
                        elog(LOG, "could not unlink file \"%s\": %m", buf);
index 034d54cabb4401fbbcabd0297114a7dd6c7a73c2..6de22ba65e148f44a7153974d4ccd1a420df036f 100644 (file)
@@ -564,7 +564,7 @@ walkdir(const char *path,
 
        while (errno = 0, (de = readdir(dir)) != NULL)
        {
-               char            subpath[MAXPGPATH];
+               char            subpath[MAXPGPATH * 2];
                struct stat fst;
                int                     sret;
 
@@ -572,7 +572,7 @@ walkdir(const char *path,
                        strcmp(de->d_name, "..") == 0)
                        continue;
 
-               snprintf(subpath, MAXPGPATH, "%s/%s", path, de->d_name);
+               snprintf(subpath, sizeof(subpath), "%s/%s", path, de->d_name);
 
                if (process_symlinks)
                        sret = stat(subpath, &fst);
index 4afb8613c38f251cd700250ac0528347f24df480..4880ec6377f832ccdb83cb7202053a5b7f4127ae 100644 (file)
@@ -179,7 +179,7 @@ FindStreamingStart(uint32 *tli)
                if (!ispartial)
                {
                        struct stat statbuf;
-                       char            fullpath[MAXPGPATH];
+                       char            fullpath[MAXPGPATH * 2];
 
                        snprintf(fullpath, sizeof(fullpath), "%s/%s", basedir, dirent->d_name);
                        if (stat(fullpath, &statbuf) != 0)
index 1a0f350f9949590e06eca1edaf3f93f0cf6aa362..ab1e13b913096e2314f9029e41b197285e0a1d11 100644 (file)
@@ -892,7 +892,7 @@ KillExistingXLOG(void)
 {
        DIR                *xldir;
        struct dirent *xlde;
-       char            path[MAXPGPATH];
+       char            path[MAXPGPATH + sizeof(XLOGDIR)];
 
        xldir = opendir(XLOGDIR);
        if (xldir == NULL)
@@ -907,7 +907,7 @@ KillExistingXLOG(void)
                if (strlen(xlde->d_name) == 24 &&
                        strspn(xlde->d_name, "0123456789ABCDEF") == 24)
                {
-                       snprintf(path, MAXPGPATH, "%s/%s", XLOGDIR, xlde->d_name);
+                       snprintf(path, sizeof(path), "%s/%s", XLOGDIR, xlde->d_name);
                        if (unlink(path) < 0)
                        {
                                fprintf(stderr, _("%s: could not delete file \"%s\": %s\n"),
@@ -939,11 +939,11 @@ KillExistingXLOG(void)
 static void
 KillExistingArchiveStatus(void)
 {
+#define ARCHSTATDIR XLOGDIR "/archive_status"
+
        DIR                *xldir;
        struct dirent *xlde;
-       char            path[MAXPGPATH];
-
-#define ARCHSTATDIR XLOGDIR "/archive_status"
+       char            path[MAXPGPATH + sizeof(ARCHSTATDIR)];
 
        xldir = opendir(ARCHSTATDIR);
        if (xldir == NULL)
@@ -959,7 +959,7 @@ KillExistingArchiveStatus(void)
                        (strcmp(xlde->d_name + 24, ".ready") == 0 ||
                         strcmp(xlde->d_name + 24, ".done") == 0))
                {
-                       snprintf(path, MAXPGPATH, "%s/%s", ARCHSTATDIR, xlde->d_name);
+                       snprintf(path, sizeof(path), "%s/%s", ARCHSTATDIR, xlde->d_name);
                        if (unlink(path) < 0)
                        {
                                fprintf(stderr, _("%s: could not delete file \"%s\": %s\n"),
index 73fecb381ba2349fb5a9a06adefcecef137657d7..6a7c9816d82144724f2feec2a6826045ed9a02f1 100644 (file)
@@ -437,7 +437,7 @@ pg_tzenumerate_next(pg_tzenum *dir)
        while (dir->depth >= 0)
        {
                struct dirent *direntry;
-               char            fullname[MAXPGPATH];
+               char            fullname[MAXPGPATH * 2];
                struct stat statbuf;
 
                direntry = ReadDir(dir->dirdesc[dir->depth], dir->dirname[dir->depth]);
@@ -454,7 +454,7 @@ pg_tzenumerate_next(pg_tzenum *dir)
                if (direntry->d_name[0] == '.')
                        continue;
 
-               snprintf(fullname, MAXPGPATH, "%s/%s",
+               snprintf(fullname, sizeof(fullname), "%s/%s",
                                 dir->dirname[dir->depth], direntry->d_name);
                if (stat(fullname, &statbuf) != 0)
                        ereport(ERROR,