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
This commit is contained in:
parent
da3ea048ca
commit
e930c872b6
@ -8744,7 +8744,7 @@ do_pg_backup_start(const char *backupidstr, bool fast, List **tablespaces,
|
|||||||
errmsg("backup label too long (max %d bytes)",
|
errmsg("backup label too long (max %d bytes)",
|
||||||
MAXPGPATH)));
|
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
|
* Mark backup active in shared memory. We must do full-page WAL writes
|
||||||
|
Loading…
x
Reference in New Issue
Block a user