* 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 <egg...@cs.ucla.edu> + 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 <stdlib.h> -/* Get explicit_bzero, memcpy. */ +/* Get memcpy, memset_explicit. */ #include <string.h> /* Get errno. */ @@ -107,11 +107,11 @@ fread_file (FILE *stream, int flags, size_t *length) { char *smaller_buf = malloc (size + 1); if (smaller_buf == 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 = 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 = realloc (buf, alloc))) @@ -168,7 +168,7 @@ fread_file (FILE *stream, int flags, size_t *length) } if (flags & RF_SENSITIVE) - explicit_bzero (buf, alloc); + memset_explicit (buf, 0, alloc); free (buf); errno = save_errno; @@ -206,7 +206,7 @@ read_file (const char *filename, int flags, size_t *length) 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 Depends-on: -explicit_bzero fopen-gnu free-posix fstat ftello malloc-posix +memset_explicit realloc-posix stdint sys_stat -- 2.37.2