Re: Replace px_memset() with explicit_bzero()

From: Peter Eisentraut <peter(at)eisentraut(dot)org>
To: Sehrope Sarkuni <sehrope(at)jackdb(dot)com>, Daniel Gustafsson <daniel(at)yesql(dot)se>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Replace px_memset() with explicit_bzero()
Date: 2026-09-01 12:23:16
Message-ID: 1d13668c-14af-45eb-8459-58e8d27f220b@eisentraut.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 25.08.26 14:27, Sehrope Sarkuni wrote:
> I eyeballed the patch. Looks mechanical and fine.
>
> One thing stood out, but it's from the existing code:
>
>
> diff --git a/contrib/pgcrypto/crypt-sha.c b/contrib/pgcrypto/crypt-sha.c
> index 8191ba02b23..eab86f8206c 100644
> --- a/contrib/pgcrypto/crypt-sha.c
> +++ b/contrib/pgcrypto/crypt-sha.c
> @@ -477,7 +477,7 @@ px_crypt_shacrypt(const char *pw, const char *salt,
> char *passwd, unsigned dstle
>   memcpy(cp, sha_buf_tmp, block);
>
>   /* Make sure we don't leave something important behind */
> - px_memset(&sha_buf_tmp, 0, sizeof sha_buf);
> + explicit_bzero(&sha_buf_tmp, sizeof sha_buf);
>
>   /*-
>   * 21. Repeat a loop according to the number specified in the rounds=<N>
>
>
> That's sha_buf in the sizeof but we're zeroing out sha_buf_tmp.
>
> They're both of length PX_SHACRYPT_DIGEST_MAX_LEN so the result is the
> same. It just reads weird.
>
> Might as well fix that now too if going to touch that line.

Thanks. I committed that fix along with the rest of the patch.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2026-09-01 12:24:16 Re: pgcrypto: remove useless px_memset() and BF_ASM
Previous Message Bertrand Drouvot 2026-09-01 12:19:34 Re: pgstat: Flush some statistics within running transactions, take 2