From 642b04a4ff67d494e9b2ac92464d49be29405601 Mon Sep 17 00:00:00 2001 From: xue_meng_en <1836611252@qq.com> Date: Tue, 30 Aug 2022 11:00:10 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9B=9E=E5=90=88=E4=B8=BB=E7=BA=BFslot=5Fname?= =?UTF-8?q?=E6=A0=A1=E9=AA=8C=E8=A7=84=E5=88=99=E7=9B=B8=E5=85=B3=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E5=8F=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/gausskernel/storage/replication/slot.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/gausskernel/storage/replication/slot.cpp b/src/gausskernel/storage/replication/slot.cpp index 0785932f7..cabcd08c1 100755 --- a/src/gausskernel/storage/replication/slot.cpp +++ b/src/gausskernel/storage/replication/slot.cpp @@ -125,29 +125,31 @@ bool ReplicationSlotValidateName(const char *name, int elevel) { const char *cp = NULL; - if (name == NULL) { + if (name == NULL || strlen(name) == 0) { ereport(elevel, (errcode(ERRCODE_INVALID_NAME), errmsg("replication slot name should not be NULL."))); return false; } - if (strlen(name) == 0) { - ereport(elevel, (errcode(ERRCODE_INVALID_NAME), errmsg("replication slot name \"%s\" is too short", name))); - return false; - } - if (strlen(name) >= NAMEDATALEN) { ereport(elevel, (errcode(ERRCODE_NAME_TOO_LONG), errmsg("replication slot name \"%s\" is too long", name))); return false; } + if ((strlen(name) == 1 && name[0] == '.') || + (strlen(name) == strlen("..") && strncmp(name, "..", strlen("..")) == 0)) { + ereport(elevel, (errcode(ERRCODE_INVALID_NAME), + errmsg("'.' and '..' are not allowed to be slot names independently."))); + } + for (cp = name; *cp; cp++) { if (!((*cp >= 'a' && *cp <= 'z') || (*cp >= '0' && *cp <= '9') || (*cp == '_') || (*cp == '?') || - (*cp == '<') || (*cp == '!') || (*cp == '-') || (*cp == '.'))) { + (*cp == '.') || (*cp == '-'))) { ereport(elevel, (errcode(ERRCODE_INVALID_NAME), errmsg("replication slot name \"%s\" contains invalid character", name), errhint("Replication slot names may only contain lower letters, " - "numbers and the underscore character."))); + "numbers and the 4 following special characters: '_', '?', '.', '-'.\n" + "'.' and '..' are also not allowed to be slot names independently."))); return false; } }