From eada31bc1320088600bb0963b43397dbe0c21b91 Mon Sep 17 00:00:00 2001 From: Luan-233 <2533556772@qq.com> Date: Fri, 28 Jul 2023 16:42:01 +0800 Subject: [PATCH] fix a bug when modify the parameter audit_data_format, if length is more than MAX_LENGTH, the errorcode is not the expected one. --- src/common/backend/utils/misc/guc.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/common/backend/utils/misc/guc.cpp b/src/common/backend/utils/misc/guc.cpp index d5f45e920..08c83557f 100755 --- a/src/common/backend/utils/misc/guc.cpp +++ b/src/common/backend/utils/misc/guc.cpp @@ -8580,6 +8580,11 @@ static void replace_config_value(char** optlines, char* name, char* value, confi rc = snprintf_s(newline, MAX_PARAM_LEN, MAX_PARAM_LEN - 1, "%s = %s\n", name, value); break; case PGC_STRING: + if (strlen(name) + strlen(value) + 6 >= MAX_PARAM_LEN) { + pfree(newline); + ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), + errmsg("too long for GUC parameter."))); + } rc = snprintf_s(newline, MAX_PARAM_LEN, MAX_PARAM_LEN - 1, "%s = '%s'\n", name, value); break; }