aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNoah Misch <noah@leadboat.com>2014-08-18 22:59:31 -0400
committerNoah Misch <noah@leadboat.com>2014-08-18 22:59:31 -0400
commitfb2aece8ae4e6f23310d7c87c7da3fec6f5df3a1 (patch)
tree78dfd07962f4a43f8b23ad8613441a3a018236a5 /src
parent7fc5f1a3550ca9395051b592df150de79804131a (diff)
downloadpostgresql-fb2aece8ae4e6f23310d7c87c7da3fec6f5df3a1.tar.gz
postgresql-fb2aece8ae4e6f23310d7c87c7da3fec6f5df3a1.zip
Replace a few strncmp() calls with strlcpy().
strncmp() is a specialized API unsuited for routine copying into fixed-size buffers. On a system where the length of a single filename can exceed MAXPGPATH, the pg_archivecleanup change prevents a simple crash in the subsequent strlen(). Few filesystems support names that long, and calling pg_archivecleanup with untrusted input is still not a credible use case. Therefore, no back-patch. David Rowley
Diffstat (limited to 'src')
-rw-r--r--src/backend/access/transam/xlogarchive.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/backend/access/transam/xlogarchive.c b/src/backend/access/transam/xlogarchive.c
index 37745dce890..047efa2672f 100644
--- a/src/backend/access/transam/xlogarchive.c
+++ b/src/backend/access/transam/xlogarchive.c
@@ -459,7 +459,8 @@ KeepFileRestoredFromArchive(char *path, char *xlogfname)
xlogfpath, oldpath)));
}
#else
- strncpy(oldpath, xlogfpath, MAXPGPATH);
+ /* same-size buffers, so this never truncates */
+ strlcpy(oldpath, xlogfpath, MAXPGPATH);
#endif
if (unlink(oldpath) != 0)
ereport(FATAL,