aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Gustafsson <dgustafsson@postgresql.org>2024-07-02 11:16:56 +0200
committerDaniel Gustafsson <dgustafsson@postgresql.org>2024-07-02 11:16:56 +0200
commite930c872b65c19c8950556fa94aa9ab53b2919b0 (patch)
tree5dd981f75405cbce88323a61ba3a438a640ad1c0
parentda3ea048ca568f570cb579c090cf1a84554b8bec (diff)
downloadpostgresql-e930c872b65c19c8950556fa94aa9ab53b2919b0.tar.gz
postgresql-e930c872b65c19c8950556fa94aa9ab53b2919b0.zip
Use safe string copy routine
Using memcpy with strlen as the size parameter will not take the NULL terminator into account, relying instead on the destination buffer being properly initialized. Replace with strlcpy which is a safer alternative, and more in line with how we handle copying strings elsewhere. Author: Ranier Vilela <ranier.vf@gmail.com> Discussion: https://postgr.es/m/CAEudQApAsbLsQ+gGiw-hT+JwGhgogFa_=5NUkgFO6kOPxyNidQ@mail.gmail.com
-rw-r--r--src/backend/access/transam/xlog.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index d36272ab4ff..33e27a6e72c 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -8744,7 +8744,7 @@ do_pg_backup_start(const char *backupidstr, bool fast, List **tablespaces,
errmsg("backup label too long (max %d bytes)",
MAXPGPATH)));
- memcpy(state->name, backupidstr, strlen(backupidstr));
+ strlcpy(state->name, backupidstr, sizeof(state->name));
/*
* Mark backup active in shared memory. We must do full-page WAL writes