diff --git a/src/common/backend/utils/error/elog.cpp b/src/common/backend/utils/error/elog.cpp index 989e071713da92b4a491bc6d540afa313e638a06..6fe7f4c5c91a6273662991f9d680c7d9cb6e4084 100644 --- a/src/common/backend/utils/error/elog.cpp +++ b/src/common/backend/utils/error/elog.cpp @@ -4517,6 +4517,8 @@ static char* mask_Password_internal(const char* query_string) if (query_string[position[i] + length[i] - 1] == ';') { length[i]--; } + curStmtType = 0; + isPassword = false; } /* @@ -4546,7 +4548,7 @@ static char* mask_Password_internal(const char* query_string) char* maskBegin = mask_string + (position[i] - truncateLen); int copySize = strlen(mask_string) - (position[i] - truncateLen) - length[i] + 1; - if (copySize > 0) { + if ((position[i] - truncateLen) >= 0 && copySize > 0) { rc = memmove_s(maskBegin + maskLen, copySize, maskBegin + length[i], copySize); securec_check(rc, "", ""); rc = memset_s(maskBegin, maskLen, '*', maskLen); diff --git a/src/test/regress/expected/hw_test_operate_user.out b/src/test/regress/expected/hw_test_operate_user.out index af250f02bfa9b9affa5818ca62e057da2aa4b999..ca0c8f5ffd0a027b4db5a891ab41971f18ed6e39 100644 --- a/src/test/regress/expected/hw_test_operate_user.out +++ b/src/test/regress/expected/hw_test_operate_user.out @@ -18,3 +18,13 @@ ERROR: Permission denied. reset role; drop role test_myrole001; drop role test_myrole002; +alter user u1 identified by aswd3456 replace dfg1637484kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkklll; +ERROR: Password must be quoted +alter user u1 ACCOUNT LOCK PASSWORD EXPIRE NEVER PASSWORD EXPIRE NEVER ACCOUNT UNLOCK ACCOUNT UNLOCK ACCOUNT UNLOCK ACCOUNT UNLOCK; +ERROR: syntax error at or near "PASSWORD" +LINE 1: alter user u1 ACCOUNT LOCK PASSWORD EXPIRE NEVER ... + ^ +alter user u1 lock password expir never lock password expire never lock password expire never lock; +ERROR: syntax error at or near "lock" +LINE 1: alter user u1 lock password expir never lock password expire... + ^ diff --git a/src/test/regress/sql/hw_test_operate_user.sql b/src/test/regress/sql/hw_test_operate_user.sql index 10a167d7890516ab8e195719e75b5020f6a23a8d..b1a106925baa2bd75856adfd0600d190f69fd6aa 100644 --- a/src/test/regress/sql/hw_test_operate_user.sql +++ b/src/test/regress/sql/hw_test_operate_user.sql @@ -18,3 +18,7 @@ alter role test_myrole002 rename to temp_myrole; reset role; drop role test_myrole001; drop role test_myrole002; + +alter user u1 identified by aswd3456 replace dfg1637484kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkklll; +alter user u1 ACCOUNT LOCK PASSWORD EXPIRE NEVER PASSWORD EXPIRE NEVER ACCOUNT UNLOCK ACCOUNT UNLOCK ACCOUNT UNLOCK ACCOUNT UNLOCK; +alter user u1 lock password expir never lock password expire never lock password expire never lock; \ No newline at end of file