]> granicus.if.org Git - postgresql/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, 17 Apr 2017 17:59:46 +0000 (13:59 -0400)
This addresses the new warning types -Wformat-truncation
-Wformat-overflow that are part of -Wall, via -Wformat, in GCC 7.

23 files changed:
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/adt/genfile.c
src/backend/utils/cache/relcache.c
src/backend/utils/error/elog.c
src/backend/utils/time/snapmgr.c
src/bin/pg_archivecleanup/pg_archivecleanup.c
src/bin/pg_basebackup/pg_receivewal.c
src/bin/pg_resetwal/pg_resetwal.c
src/bin/pg_rewind/copy_fetch.c
src/common/file_utils.c
src/timezone/pgtz.c

index e4d057e18e21e98ed3f31be4c20935d1da631522..5703032397915ab11bd758a65c75393339fbae08 100644 (file)
@@ -57,7 +57,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[MAXFNAMELEN];          /* the file we need to
                                                                                                                 * get from archive */
@@ -259,9 +259,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 d7f65a5e99523e18ca8fd2be55c588a1a9675793..60dcb67a20322e9ddf0c85461fc48193482cf482 100644 (file)
@@ -1203,7 +1203,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
@@ -1234,7 +1234,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 45ed58ea3431574e425988a340111379f3ed8da8..c7667879c65894dece013add4d6badc3e5cbd077 100644 (file)
@@ -4102,7 +4102,7 @@ CleanupBackupHistory(void)
 {
        DIR                *xldir;
        struct dirent *xlde;
-       char            path[MAXPGPATH];
+       char            path[MAXPGPATH + sizeof(XLOGDIR)];
 
        xldir = AllocateDir(XLOGDIR);
        if (xldir == NULL)
@@ -4120,7 +4120,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);
                        }
@@ -10389,7 +10389,7 @@ do_pg_start_backup(const char *backupidstr, bool fast, TimeLineID *starttli_p,
                /* 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;
index 235dc26405556e28b67ab6507e4666c125e97a1f..15d06892d3a60d9341006d2fa79557d98d8b57ab 100644 (file)
@@ -606,7 +606,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)
@@ -636,7 +636,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 e3a7ad5e9ab20fc622d1351c28c4524743402e13..3ee0dd5aa4541fc3470c38356d8f31019ffa42b0 100644 (file)
@@ -959,7 +959,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;
 
@@ -1011,7 +1011,7 @@ sendDir(char *path, int basepathlen, bool sizeonly, List *tablespaces,
                if (excludeFound)
                        continue;
 
-               snprintf(pathbuf, MAXPGPATH, "%s/%s", path, de->d_name);
+               snprintf(pathbuf, sizeof(pathbuf), "%s/%s", path, de->d_name);
 
                /* Skip pg_control here to back up it last */
                if (strcmp(pathbuf, "./global/pg_control") == 0)
index 12ebadca815097d9d138b82146b777d6374390f6..0c174be8ed78334380d22e16b844a9865dca961b 100644 (file)
@@ -2613,7 +2613,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 227960452d62c57d87b9b0ba38b81af4b4915564..358ec28932126eeba54937398c3f7242d94e53a0 100644 (file)
@@ -1868,7 +1868,7 @@ CheckPointSnapBuild(void)
        XLogRecPtr      redo;
        DIR                *snap_dir;
        struct dirent *snap_de;
-       char            path[MAXPGPATH];
+       char            path[MAXPGPATH + 21];
 
        /*
         * We start off with a minimum of the last redo pointer. No new replication
@@ -1895,7 +1895,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 6ac0ce69c65017eeb5552158341cfe13c11cef1e..e8ad0f7b39475fd22e6d34e971a454b25445dfa7 100644 (file)
@@ -1023,13 +1023,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))
@@ -1259,7 +1259,7 @@ RestoreSlotFromDisk(const char *name)
 {
        ReplicationSlotOnDisk cp;
        int                     i;
-       char            path[MAXPGPATH];
+       char            path[MAXPGPATH + 22];
        int                     fd;
        bool            restored = false;
        int                     readBytes;
index dffe28376b150fc62c09cc7622f96d75f18962ce..1e2691685a6a9cfbeb0fe170f6352837ab8782aa 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 b14979496c79d3ea5df80682456fdf95982ac167..81d96a4cc096e4d6c35379af5b061ad64897e2c2 100644 (file)
@@ -2705,7 +2705,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;
 
@@ -2753,7 +2753,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)
@@ -2794,7 +2794,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)
@@ -2835,7 +2835,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)
@@ -3022,7 +3022,7 @@ walkdir(const char *path,
 
        while ((de = ReadDirExtended(dir, path, elevel)) != NULL)
        {
-               char            subpath[MAXPGPATH];
+               char            subpath[MAXPGPATH * 2];
                struct stat fst;
                int                     sret;
 
@@ -3032,7 +3032,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 b883dfc657ea1b550486f789755f90eaabbca81d..f331e7bc21ef31e74b72822b410c49d7af0a830e 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,
@@ -104,7 +104,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)
@@ -145,7 +145,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);
@@ -308,7 +308,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 b65b63b721f0fd4fcb186ec4a17fc90c100a26fa..387849e22c17ebc306c533ace59eb8bff2da3ea8 100644 (file)
@@ -307,9 +307,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 6d56638208b5bda914c9eeb8e8a40e3e190b34e9..b0418b18dceb080c1292bf1a03d978b87f2549c7 100644 (file)
@@ -41,7 +41,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);
 
@@ -58,7 +58,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)
                {
@@ -86,7 +86,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;
 
        /*
@@ -104,7 +104,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 */
@@ -124,7 +124,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);
        }
@@ -172,7 +172,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;
@@ -215,7 +215,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 8d0a236e6d5bc339408bf7e645c4158bc34d22b5..32d6a6668819dd142333d507e294f2ad0117b01a 100644 (file)
@@ -522,7 +522,7 @@ pg_ls_dir_files(FunctionCallInfo fcinfo, char *dir)
        {
                Datum           values[3];
                bool            nulls[3];
-               char            path[MAXPGPATH];
+               char            path[MAXPGPATH * 2];
                struct          stat attrib;
                HeapTuple       tuple;
 
@@ -531,7 +531,7 @@ pg_ls_dir_files(FunctionCallInfo fcinfo, char *dir)
                        continue;
 
                /* Get the file info */
-               snprintf(path, MAXPGPATH, "%s/%s", fctx->location, de->d_name);
+               snprintf(path, sizeof(path), "%s/%s", fctx->location, de->d_name);
                if (stat(path, &attrib) < 0)
                        ereport(ERROR,
                                        (errcode_for_file_access(),
index ddb948528b3c274b4410577a386fb84e7614164e..5bf02d4c0e63342d9c717f8e54955ac57dd1f26b 100644 (file)
@@ -6074,7 +6074,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
@@ -6116,7 +6116,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 6e83cbedabfa18ec62d63f6281b80f4634c2068b..22004cb81920ada33db7ab47e9dbea6776f94f80 100644 (file)
@@ -2228,7 +2228,7 @@ static void
 setup_formatted_log_time(void)
 {
        pg_time_t       stamp_time;
-       char            msbuf[8];
+       char            msbuf[13];
 
        if (!saved_timeval_set)
        {
index 3d92494e0bad453761aafee4a990854506bd5cdb..3a3a25a0c36ba5577ca53694f34202b01cec9e73 100644 (file)
@@ -1578,7 +1578,7 @@ XactHasExportedSnapshots(void)
 void
 DeleteAllExportedSnapshotFiles(void)
 {
-       char            buf[MAXPGPATH];
+       char            buf[MAXPGPATH + sizeof(SNAPSHOT_EXPORT_DIR)];
        DIR                *s_dir;
        struct dirent *s_de;
 
@@ -1599,7 +1599,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 f1651d42733fe1a9c9b0ff59ba447366479c1779..17609555860ba8ba646fbb17acdc072314827334 100644 (file)
@@ -32,7 +32,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[MAXFNAMELEN];          /* 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 15348ada58daed991de7dbb3fa9631b2f509824a..1a9fe81be14b4918f44ed23007da6d957f367d6b 100644 (file)
@@ -244,7 +244,7 @@ FindStreamingStart(uint32 *tli)
                if (!ispartial && !iscompress)
                {
                        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)
@@ -267,7 +267,7 @@ FindStreamingStart(uint32 *tli)
                        int             fd;
                        char    buf[4];
                        int             bytes_out;
-                       char    fullpath[MAXPGPATH];
+                       char    fullpath[MAXPGPATH * 2];
 
                        snprintf(fullpath, sizeof(fullpath), "%s/%s", basedir, dirent->d_name);
 
index bcb9ed938f5d73767d41e0e8cf0da0340a2b09e8..73bd9fe6ecbe01a10015c743d4b984fcfa4c6335 100644 (file)
@@ -958,7 +958,7 @@ KillExistingXLOG(void)
 {
        DIR                *xldir;
        struct dirent *xlde;
-       char            path[MAXPGPATH];
+       char            path[MAXPGPATH + sizeof(XLOGDIR)];
 
        xldir = opendir(XLOGDIR);
        if (xldir == NULL)
@@ -973,7 +973,7 @@ KillExistingXLOG(void)
                if (IsXLogFileName(xlde->d_name) ||
                        IsPartialXLogFileName(xlde->d_name))
                {
-                       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"),
@@ -1005,11 +1005,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)
@@ -1027,7 +1027,7 @@ KillExistingArchiveStatus(void)
                         strcmp(xlde->d_name + XLOG_FNAME_LEN, ".partial.ready") == 0 ||
                         strcmp(xlde->d_name + XLOG_FNAME_LEN, ".partial.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 f8d3dfecfa1cfdf54fae2c53ce249a2f97257f6c..347d4e4d4ca70a531716f50872156e40da441073 100644 (file)
@@ -65,14 +65,14 @@ recurse_dir(const char *datadir, const char *parentpath,
        while (errno = 0, (xlde = readdir(xldir)) != NULL)
        {
                struct stat fst;
-               char            fullpath[MAXPGPATH];
-               char            path[MAXPGPATH];
+               char            fullpath[MAXPGPATH * 2];
+               char            path[MAXPGPATH * 2];
 
                if (strcmp(xlde->d_name, ".") == 0 ||
                        strcmp(xlde->d_name, "..") == 0)
                        continue;
 
-               snprintf(fullpath, MAXPGPATH, "%s/%s", fullparentpath, xlde->d_name);
+               snprintf(fullpath, sizeof(fullpath), "%s/%s", fullparentpath, xlde->d_name);
 
                if (lstat(fullpath, &fst) < 0)
                {
@@ -93,9 +93,9 @@ recurse_dir(const char *datadir, const char *parentpath,
                }
 
                if (parentpath)
-                       snprintf(path, MAXPGPATH, "%s/%s", parentpath, xlde->d_name);
+                       snprintf(path, sizeof(path), "%s/%s", parentpath, xlde->d_name);
                else
-                       snprintf(path, MAXPGPATH, "%s", xlde->d_name);
+                       snprintf(path, sizeof(path), "%s", xlde->d_name);
 
                if (S_ISREG(fst.st_mode))
                        callback(path, FILE_TYPE_REGULAR, fst.st_size, NULL);
index 72b0565c7100eb17d961c3a092d014421fc53cf8..218b83f3913e6e163ad59736abd01b6eb8be8b95 100644 (file)
@@ -166,7 +166,7 @@ walkdir(const char *path,
 
        while (errno = 0, (de = readdir(dir)) != NULL)
        {
-               char            subpath[MAXPGPATH];
+               char            subpath[MAXPGPATH * 2];
                struct stat fst;
                int                     sret;
 
@@ -174,7 +174,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 826857d9430b9a4240b4e908c4c3bf603c0420d5..b7cfc5f5ac831f6a1310a80ef4ccfab5ef5719ce 100644 (file)
@@ -412,7 +412,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]);
@@ -429,7 +429,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,