summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--contrib/pgcrypto/crypt-sha.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/contrib/pgcrypto/crypt-sha.c b/contrib/pgcrypto/crypt-sha.c
index 7e9440ca784..7ec21771a83 100644
--- a/contrib/pgcrypto/crypt-sha.c
+++ b/contrib/pgcrypto/crypt-sha.c
@@ -46,6 +46,7 @@
#include "postgres.h"
#include "common/string.h"
+#include "mb/pg_wchar.h"
#include "miscadmin.h"
#include "px-crypt.h"
@@ -58,7 +59,7 @@ typedef enum
PGCRYPTO_SHA_UNKOWN
} PGCRYPTO_SHA_t;
-static unsigned char _crypt_itoa64[64 + 1] =
+static const char _crypt_itoa64[64 + 1] =
"./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
/*
@@ -321,10 +322,13 @@ px_crypt_shacrypt(const char *pw, const char *salt, char *passwd, unsigned dstle
if (*ep != '$')
{
- if (isalpha(*ep) || isdigit(*ep) || (*ep == '.') || (*ep == '/'))
+ if (strchr(_crypt_itoa64, *ep) != NULL)
appendStringInfoCharMacro(decoded_salt, *ep);
else
- elog(ERROR, "invalid character in salt string: \"%c\"", *ep);
+ ereport(ERROR,
+ errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+ errmsg("invalid character in salt string: \"%.*s\"",
+ pg_mblen(ep), ep));
}
else
{
@@ -602,8 +606,6 @@ px_crypt_shacrypt(const char *pw, const char *salt, char *passwd, unsigned dstle
elog(ERROR, "unsupported digest length");
}
- *cp = '\0';
-
/*
* Copy over result to specified buffer.
*