From 58f8b19f9a23cac69dbd5d4064330accb5c02517 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cross-=E7=BD=97?= <1165977584@qq.com> Date: Wed, 19 Jul 2023 08:45:05 +0000 Subject: [PATCH] =?UTF-8?q?update=20src/gausskernel/process/postmaster/pga?= =?UTF-8?q?rch.cpp.=20=E4=BF=AE=E5=A4=8Dsnprintf=5Fs=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E4=B8=8D=E8=A7=84=E8=8C=83=E5=AF=BC=E8=87=B4=E5=BD=92=E6=A1=A3?= =?UTF-8?q?=E8=B7=AF=E5=BE=84=E9=94=99=E8=AF=AF=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Cross-罗 <1165977584@qq.com> --- src/gausskernel/process/postmaster/pgarch.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/gausskernel/process/postmaster/pgarch.cpp b/src/gausskernel/process/postmaster/pgarch.cpp index 4322ae26a..64d2b6203 100755 --- a/src/gausskernel/process/postmaster/pgarch.cpp +++ b/src/gausskernel/process/postmaster/pgarch.cpp @@ -611,6 +611,7 @@ static bool PgarchArchiveXlogToDest(const char* xlog) int fdDest = -1; char srcPath[PATH_MAX + 1] = {0}; char destPath[PATH_MAX + 1] = {0}; + char archPath[PATH_MAX + 1] = {0}; char activitymsg[MAXFNAMELEN + 16]; long int fileBytes = 0; int rc = 0; @@ -631,17 +632,17 @@ static bool PgarchArchiveXlogToDest(const char* xlog) if (retVal == NULL) { ereport(FATAL, (errmsg_internal("realpath dest %s failed:%m\n", u_sess->attr.attr_storage.XLogArchiveDest))); } - rc = snprintf_s(destPath, PATH_MAX, PATH_MAX - 1, "%s/%s", destPath, xlog); + rc = snprintf_s(archPath, PATH_MAX, PATH_MAX - 1, "%s/%s", destPath, xlog); securec_check_ss(rc, "\0", "\0"); if ((fdSrc = open(srcPath, O_RDONLY)) >= 0) { - if ((fdDest = open(destPath, O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR)) >= 0) { + if ((fdDest = open(archPath, O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR)) >= 0) { char pbuff[ARCHIVE_BUF_SIZE] = {0}; while ((fileBytes = read(fdSrc, pbuff, sizeof(pbuff))) > 0) { if (write(fdDest, pbuff, fileBytes) != fileBytes) { close(fdSrc); - ereport(FATAL, (errmsg_internal("could not write file\"%s\":%m\n", destPath))); + ereport(FATAL, (errmsg_internal("could not write file\"%s\":%m\n", archPath))); } (void)memset_s(pbuff, sizeof(pbuff), 0, sizeof(pbuff)); } @@ -663,7 +664,7 @@ static bool PgarchArchiveXlogToDest(const char* xlog) return true; } else { close(fdSrc); - ereport(FATAL, (errmsg_internal("could not open archive dest file \"%s\":%m\n", destPath))); + ereport(FATAL, (errmsg_internal("could not open archive dest file \"%s\":%m\n", archPath))); } } else { ereport(FATAL, (errmsg_internal("could not open archive src file \"%s\":%m\n", srcPath)));