From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS22989 209.51.188.0/24 X-Spam-Status: No, score=-4.2 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id E551C1F910 for ; Mon, 28 Nov 2022 04:56:28 +0000 (UTC) Authentication-Results: dcvr.yhbt.net; dkim=pass (1024-bit key; unprotected) header.d=cs.ucla.edu header.i=@cs.ucla.edu header.b="osKyYlXv"; dkim-atps=neutral Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ozWBS-0007oj-RT; Sun, 27 Nov 2022 23:55:58 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ozWBR-0007nk-0S for bug-gnulib@gnu.org; Sun, 27 Nov 2022 23:55:57 -0500 Received: from zimbra.cs.ucla.edu ([131.179.128.68]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ozWBO-00005j-Mb for bug-gnulib@gnu.org; Sun, 27 Nov 2022 23:55:56 -0500 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 7080216006F for ; Sun, 27 Nov 2022 20:55:53 -0800 (PST) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id iFyWfWIHLNKB; Sun, 27 Nov 2022 20:55:52 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 8AE34160060; Sun, 27 Nov 2022 20:55:52 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.9.2 zimbra.cs.ucla.edu 8AE34160060 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cs.ucla.edu; s=78364E5A-2AF3-11ED-87FA-8298ECA2D365; t=1669611352; bh=tV2ryp3E/mO1+Aueet+5feePrpPdYs3+KU4L4FablvM=; h=From:To:Subject:Date:Message-Id:MIME-Version: Content-Transfer-Encoding; b=osKyYlXvPquQxFoVCazLqmc60X5cpTRSgXfurxWqDxPme1vgf4C9QTectBfQ3tdGz mCVkHKJQWo5vDf4PomYxU4B5/i9OfBcfSH/gnZR/sir+2T1RBBcNe3SSaP8g9hHruz wyXhtrE6nSeWfm0nGF3jWn+CmUtNykrSGxJY1/gY= X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id uOAuSC0uUEje; Sun, 27 Nov 2022 20:55:52 -0800 (PST) Received: from localhost.localdomain (cpe-172-91-119-151.socal.res.rr.com [172.91.119.151]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 6200D160043; Sun, 27 Nov 2022 20:55:52 -0800 (PST) From: Paul Eggert To: bug-gnulib@gnu.org Cc: Paul Eggert Subject: [PROPOSED 2/4] read-file: use memset_explicit Date: Sun, 27 Nov 2022 20:55:41 -0800 Message-Id: <20221128045543.1355731-3-eggert@cs.ucla.edu> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20221128045543.1355731-1-eggert@cs.ucla.edu> References: <20221128045543.1355731-1-eggert@cs.ucla.edu> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=131.179.128.68; envelope-from=eggert@cs.ucla.edu; helo=zimbra.cs.ucla.edu X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: bug-gnulib@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gnulib discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnulib-bounces+normalperson=yhbt.net@gnu.org Sender: bug-gnulib-bounces+normalperson=yhbt.net@gnu.org * lib/read-file.c (fread_file, read_file): Use memset_explicit instead of explicit_bzero. * modules/read-file (Depends-on): Depend on memset_explicit instead of on explicit_bzero. --- ChangeLog | 6 ++++++ lib/read-file.c | 12 ++++++------ modules/read-file | 2 +- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 80f8d2c9cd..2d29d1f646 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2022-11-27 Paul Eggert =20 + read-file: use memset_explicit + * lib/read-file.c (fread_file, read_file): + Use memset_explicit instead of explicit_bzero. + * modules/read-file (Depends-on): Depend on memset_explicit + instead of on explicit_bzero. + memset_explicit: new module * doc/posix-functions/memset_explicit.texi, lib/memset_explicit.c: * m4/memset_explicit.m4, modules/memset_explicit: diff --git a/lib/read-file.c b/lib/read-file.c index 7e02a4380e..c63aaf0db4 100644 --- a/lib/read-file.c +++ b/lib/read-file.c @@ -31,7 +31,7 @@ /* Get malloc, realloc, free. */ #include =20 -/* Get explicit_bzero, memcpy. */ +/* Get memcpy, memset_explicit. */ #include =20 /* Get errno. */ @@ -107,11 +107,11 @@ fread_file (FILE *stream, int flags, size_t *length= ) { char *smaller_buf =3D malloc (size + 1); if (smaller_buf =3D=3D NULL) - explicit_bzero (buf + size, alloc - size); + memset_explicit (buf + size, 0, alloc - size); else { memcpy (smaller_buf, buf, size); - explicit_bzero (buf, alloc); + memset_explicit (buf, 0, alloc); free (buf); buf =3D smaller_buf; } @@ -154,7 +154,7 @@ fread_file (FILE *stream, int flags, size_t *length) break; } memcpy (new_buf, buf, save_alloc); - explicit_bzero (buf, save_alloc); + memset_explicit (buf, 0, save_alloc); free (buf); } else if (!(new_buf =3D realloc (buf, alloc))) @@ -168,7 +168,7 @@ fread_file (FILE *stream, int flags, size_t *length) } =20 if (flags & RF_SENSITIVE) - explicit_bzero (buf, alloc); + memset_explicit (buf, 0, alloc); =20 free (buf); errno =3D save_errno; @@ -206,7 +206,7 @@ read_file (const char *filename, int flags, size_t *l= ength) if (out) { if (flags & RF_SENSITIVE) - explicit_bzero (out, *length); + memset_explicit (out, 0, *length); free (out); } return NULL; diff --git a/modules/read-file b/modules/read-file index e087c3567e..bdfdec8488 100644 --- a/modules/read-file +++ b/modules/read-file @@ -7,12 +7,12 @@ lib/read-file.c m4/read-file.m4 =20 Depends-on: -explicit_bzero fopen-gnu free-posix fstat ftello malloc-posix +memset_explicit realloc-posix stdint sys_stat --=20 2.37.2