diff --git a/contrib/chkpass/chkpass.c b/contrib/chkpass/chkpass.c index 283ad9a..b361718 100644 --- a/contrib/chkpass/chkpass.c +++ b/contrib/chkpass/chkpass.c @@ -75,10 +75,24 @@ chkpass_in(PG_FUNCTION_ARGS) (errcode(ERRCODE_DATA_EXCEPTION), errmsg("password \"%s\" is weak", str))); +#ifndef RANDOMIZE_ALLOCATED_MEMORY result = (chkpass *) palloc(sizeof(chkpass)); mysalt[0] = salt_chars[random() & 0x3f]; mysalt[1] = salt_chars[random() & 0x3f]; +#else + /* + * Trailing uninitialized bytes after the null character can lead to + * unstable input conversion warnings in RANDOMIZE_ALLOCATED_MEMORY + * enable build. + */ + result = (chkpass *) palloc0(sizeof(chkpass)); + + /* Instead of random salt use constant value for consistent result */ + mysalt[0] = salt_chars[1]; + mysalt[1] = salt_chars[2]; +#endif + mysalt[2] = 0; /* technically the terminator is not necessary * but I like to play safe */