diff options
author | Heikki Linnakangas <heikki.linnakangas@iki.fi> | 2016-12-12 11:55:32 +0200 |
---|---|---|
committer | Heikki Linnakangas <heikki.linnakangas@iki.fi> | 2016-12-12 11:55:32 +0200 |
commit | 58445c5c8d1424038d654ad9ee8af3724c60105e (patch) | |
tree | 9cc62e1f560ba7b3fc6287a73a100926f913d6db /contrib | |
parent | 9bbbf029dded76d7d86053ebad1c5f9ab2948904 (diff) | |
download | postgresql-58445c5c8d1424038d654ad9ee8af3724c60105e.tar.gz |
Further cleanup from the strong-random patch.
Also use the new facility for generating RADIUS authenticator requests,
and salt in chkpass extension.
Reword the error messages to be nicer. Fix bogus error code used in the
message in BackendStartup.
Diffstat (limited to 'contrib')
-rw-r--r-- | contrib/chkpass/chkpass.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/contrib/chkpass/chkpass.c b/contrib/chkpass/chkpass.c index 9425c089b5..3803ccff9a 100644 --- a/contrib/chkpass/chkpass.c +++ b/contrib/chkpass/chkpass.c @@ -17,6 +17,7 @@ #endif #include "fmgr.h" +#include "utils/backend_random.h" #include "utils/builtins.h" PG_MODULE_MAGIC; @@ -77,8 +78,12 @@ chkpass_in(PG_FUNCTION_ARGS) result = (chkpass *) palloc0(sizeof(chkpass)); - mysalt[0] = salt_chars[random() & 0x3f]; - mysalt[1] = salt_chars[random() & 0x3f]; + if (!pg_backend_random(mysalt, 2)) + ereport(ERROR, + (errmsg("could not generate random salt"))); + + mysalt[0] = salt_chars[mysalt[0] & 0x3f]; + mysalt[1] = salt_chars[mysalt[1] & 0x3f]; mysalt[2] = 0; /* technically the terminator is not necessary * but I like to play safe */ |