Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1klOcb-00085M-Kb for pgsql-hackers@arkaria.postgresql.org; Sat, 05 Dec 2020 03:52:33 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1klOca-00061M-K7 for pgsql-hackers@arkaria.postgresql.org; Sat, 05 Dec 2020 03:52:32 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1klOca-00061F-DL for pgsql-hackers@lists.postgresql.org; Sat, 05 Dec 2020 03:52:32 +0000 Received: from momjian.us ([72.94.173.45]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1klOcY-0002G8-9z for pgsql-hackers@postgresql.org; Sat, 05 Dec 2020 03:52:31 +0000 Received: from bruce by momjian.us with local (Exim 4.92) (envelope-from ) id 1klOcX-00071U-Cm; Fri, 04 Dec 2020 22:52:29 -0500 Date: Fri, 4 Dec 2020 22:52:29 -0500 From: Bruce Momjian To: Masahiko Sawada Cc: PostgreSQL-development Subject: Re: Proposed patch for key managment Message-ID: <20201205035229.GC8757@momjian.us> References: <20201202213814.GG20285@momjian.us> <20201205020803.GA8757@momjian.us> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="hQiwHBbRI9kgIhsi" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --hQiwHBbRI9kgIhsi Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Sat, Dec 5, 2020 at 12:15:13PM +0900, Masahiko Sawada wrote: > diff --git a/src/common/cryptohash_openssl.c b/src/common/cryptohash_openssl.c > index e5233daab6..a45c86fa67 100644 > --- a/src/common/cryptohash_openssl.c > +++ b/src/common/cryptohash_openssl.c > @@ -81,6 +81,8 @@ pg_cryptohash_create(pg_cryptohash_type type) > return NULL; > } > > + memset(ctx, 0, sizeof(pg_cryptohash_ctx)); > + memset(state, 0, sizeof(pg_cryptohash_state)); > ctx->data = state; > ctx->type = type; OK, I worked with Sawada-san and added the attached patch. The updated full patch is at the same URL: :-) https://github.com/postgres/postgres/compare/master...bmomjian:key.diff -- Bruce Momjian https://momjian.us EnterpriseDB https://enterprisedb.com The usefulness of a cup is in its emptiness, Bruce Lee --hQiwHBbRI9kgIhsi Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="bzero.diff" diff --git a/src/common/cryptohash_openssl.c b/src/common/cryptohash_openssl.c index e5233daab6..02dec1fd1b 100644 --- a/src/common/cryptohash_openssl.c +++ b/src/common/cryptohash_openssl.c @@ -72,14 +72,15 @@ pg_cryptohash_create(pg_cryptohash_type type) ctx = ALLOC(sizeof(pg_cryptohash_ctx)); if (ctx == NULL) return NULL; + explicit_bzero(ctx, sizeof(pg_cryptohash_ctx)); state = ALLOC(sizeof(pg_cryptohash_state)); if (state == NULL) { - explicit_bzero(ctx, sizeof(pg_cryptohash_ctx)); FREE(ctx); return NULL; } + explicit_bzero(state, sizeof(pg_cryptohash_state)); ctx->data = state; ctx->type = type; @@ -97,8 +98,6 @@ pg_cryptohash_create(pg_cryptohash_type type) if (state->evpctx == NULL) { - explicit_bzero(state, sizeof(pg_cryptohash_state)); - explicit_bzero(ctx, sizeof(pg_cryptohash_ctx)); #ifndef FRONTEND ereport(ERROR, (errcode(ERRCODE_OUT_OF_MEMORY), --hQiwHBbRI9kgIhsi--