summaryrefslogtreecommitdiff
path: root/contrib/chkpass/chkpass.c
diff options
context:
space:
mode:
authorHeikki Linnakangas2016-12-12 09:55:32 +0000
committerHeikki Linnakangas2016-12-12 09:55:32 +0000
commit58445c5c8d1424038d654ad9ee8af3724c60105e (patch)
tree9cc62e1f560ba7b3fc6287a73a100926f913d6db /contrib/chkpass/chkpass.c
parent9bbbf029dded76d7d86053ebad1c5f9ab2948904 (diff)
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/chkpass/chkpass.c')
-rw-r--r--contrib/chkpass/chkpass.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/contrib/chkpass/chkpass.c b/contrib/chkpass/chkpass.c
index 9425c089b5b..3803ccff9ac 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 */