v2-avoid-incomplete-copy-string-do_pg_backup_start.patch

application/octet-stream

Filename: v2-avoid-incomplete-copy-string-do_pg_backup_start.patch
Type: application/octet-stream
Part: 0
Message: Re: Avoid incomplete copy string (src/backend/access/transam/xlog.c)

Patch

Same data as JSON: GET /api/v1/attachments/:id/patch the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes. API reference →
Format: unified
Series: patch v2
File+
src/backend/access/transam/xlog.c 1 3
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index 330e058c5f..b1c4896c90 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -8727,14 +8727,12 @@ do_pg_backup_start(const char *backupidstr, bool fast, List **tablespaces,
 				 errmsg("WAL level not sufficient for making an online backup"),
 				 errhint("\"wal_level\" must be set to \"replica\" or \"logical\" at server start.")));
 
-	if (strlen(backupidstr) > MAXPGPATH)
+	if (strlcpy(state->name, backupidstr, sizeof(state->name)) >= sizeof(state->name))
 		ereport(ERROR,
 				(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
 				 errmsg("backup label too long (max %d bytes)",
 						MAXPGPATH)));
 
-	memcpy(state->name, backupidstr, strlen(backupidstr));
-
 	/*
 	 * Mark backup active in shared memory.  We must do full-page WAL writes
 	 * during an on-line backup even if not doing so at other times, because