aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2018-03-25 15:15:32 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2018-03-25 15:15:40 -0400
commitd0c0c894533f906b13b79813f02b2982ac675074 (patch)
tree5ee83f3b5c5769477ae735bc274179a43d4580ea /src
parentbf4a8676c316c177f395b54d3305ea4ccc838a66 (diff)
downloadpostgresql-d0c0c894533f906b13b79813f02b2982ac675074.tar.gz
postgresql-d0c0c894533f906b13b79813f02b2982ac675074.zip
Fix unsafe extraction of the OID part of a relation filename.
Commit 8694cc96b did this randomly differently from other callers of parse_filename_for_nontemp_relation(). Perhaps unsurprisingly, the randomly different way is wrong; it fails to ensure the extracted string is null-terminated. Per buildfarm member skink. Discussion: https://postgr.es/m/14453.1522001792@sss.pgh.pa.us
Diffstat (limited to 'src')
-rw-r--r--src/backend/replication/basebackup.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/backend/replication/basebackup.c b/src/backend/replication/basebackup.c
index eb6eb7206da..e4c45c50256 100644
--- a/src/backend/replication/basebackup.c
+++ b/src/backend/replication/basebackup.c
@@ -1056,7 +1056,8 @@ sendDir(const char *path, int basepathlen, bool sizeonly, List *tablespaces,
* If any other type of fork, check if there is an init fork
* with the same OID. If so, the file can be excluded.
*/
- strncpy(relOid, de->d_name, relOidChars);
+ memcpy(relOid, de->d_name, relOidChars);
+ relOid[relOidChars] = '\0';
snprintf(initForkFile, sizeof(initForkFile), "%s/%s_init",
path, relOid);