summaryrefslogtreecommitdiff
path: root/contrib/chkpass/chkpass.c
diff options
context:
space:
mode:
authorRobert Haas2014-02-01 03:25:01 +0000
committerRobert Haas2014-02-01 03:25:01 +0000
commitc7de3295ba9db6649c32568bb46b91f1160da8d3 (patch)
tree52bda214aaf8fa4bcc80eb8593c06807f2dc776d /contrib/chkpass/chkpass.c
parente01fc2377bfdb6a519aea7007a57c901c8a95da6 (diff)
parentd1981719adbcc05fa15f540e8fc4327907991fc6 (diff)
Merge branch 'master' into slot2slot2
Diffstat (limited to 'contrib/chkpass/chkpass.c')
-rw-r--r--contrib/chkpass/chkpass.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/contrib/chkpass/chkpass.c b/contrib/chkpass/chkpass.c
index 0c9fec0e67..dc66075f98 100644
--- a/contrib/chkpass/chkpass.c
+++ b/contrib/chkpass/chkpass.c
@@ -70,6 +70,7 @@ chkpass_in(PG_FUNCTION_ARGS)
char *str = PG_GETARG_CSTRING(0);
chkpass *result;
char mysalt[4];
+ char *crypt_output;
static char salt_chars[] =
"./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
@@ -92,7 +93,13 @@ chkpass_in(PG_FUNCTION_ARGS)
mysalt[1] = salt_chars[random() & 0x3f];
mysalt[2] = 0; /* technically the terminator is not necessary
* but I like to play safe */
- strcpy(result->password, crypt(str, mysalt));
+
+ if ((crypt_output = crypt(str, mysalt)) == NULL)
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+ errmsg("crypt() failed")));
+ strcpy(result->password, crypt_output);
+
PG_RETURN_POINTER(result);
}