Skip to content

Commit e930c87

Browse files
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
1 parent da3ea04 commit e930c87

File tree

1 file changed

+1
-1
lines changed
  • src/backend/access/transam

1 file changed

+1
-1
lines changed

src/backend/access/transam/xlog.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8744,7 +8744,7 @@ do_pg_backup_start(const char *backupidstr, bool fast, List **tablespaces,
87448744
errmsg("backup label too long (max %d bytes)",
87458745
MAXPGPATH)));
87468746

8747-
memcpy(state->name, backupidstr, strlen(backupidstr));
8747+
strlcpy(state->name, backupidstr, sizeof(state->name));
87488748

87498749
/*
87508750
* Mark backup active in shared memory. We must do full-page WAL writes

0 commit comments

Comments
 (0)