From f3c4c2cf735c448edd66e9f0f546547355aff1c1 Mon Sep 17 00:00:00 2001
From: Justin Pryzby <pryzbyj@telsasoft.com>
Date: Wed, 13 Jul 2022 15:06:21 -0500
Subject: [PATCH 6/6] basebackup: use port/strlcpy()

---
 src/bin/pg_basebackup/pg_basebackup.c | 3 +--
 src/bin/pg_basebackup/pg_receivewal.c | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/src/bin/pg_basebackup/pg_basebackup.c b/src/bin/pg_basebackup/pg_basebackup.c
index 22836ca01a1..28960158e7f 100644
--- a/src/bin/pg_basebackup/pg_basebackup.c
+++ b/src/bin/pg_basebackup/pg_basebackup.c
@@ -1005,8 +1005,7 @@ parse_compress_options(char *option, char **algorithm, char **detail,
 		char	   *alg;
 
 		alg = palloc((sep - option) + 1);
-		memcpy(alg, option, sep - option);
-		alg[sep - option] = '\0';
+		strlcpy(alg, option, sep - option + 1);
 
 		*algorithm = alg;
 		*detail = pstrdup(sep + 1);
diff --git a/src/bin/pg_basebackup/pg_receivewal.c b/src/bin/pg_basebackup/pg_receivewal.c
index 63207ca025e..3acf19a1201 100644
--- a/src/bin/pg_basebackup/pg_receivewal.c
+++ b/src/bin/pg_basebackup/pg_receivewal.c
@@ -161,8 +161,7 @@ parse_compress_options(char *option, char **algorithm, char **detail)
 		char	   *alg;
 
 		alg = palloc((sep - option) + 1);
-		memcpy(alg, option, sep - option);
-		alg[sep - option] = '\0';
+		strlcpy(alg, option, sep - option + 1);
 
 		*algorithm = alg;
 		*detail = pstrdup(sep + 1);
-- 
2.25.1

