diff options
author | Tobias Stoeckmann <tobias@stoeckmann.org> | 2022-07-03 11:52:44 +0200 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2022-07-09 17:34:31 +0000 |
commit | 8928883477ff32cbbb97ee0e871324812e3b5c96 (patch) | |
tree | 1ac12eefbeb297b9b17465dc23e5fab54ff3eac8 | |
parent | 19b13bf20de5b15ab87fb4019ec910ef3216129f (diff) |
Use explicit_bzero if available
Optimizing compilers may remove the bzero call because it is followed
by free. The function explicit_bzero avoids this optimization. Use it
if it is available.
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
-rw-r--r-- | AuDispose.c | 4 | ||||
-rw-r--r-- | AuRead.c | 8 | ||||
-rw-r--r-- | configure.ac | 2 |
3 files changed, 13 insertions, 1 deletions
diff --git a/AuDispose.c b/AuDispose.c index 355224d..b24d21c 100644 --- a/AuDispose.c +++ b/AuDispose.c @@ -38,7 +38,11 @@ XauDisposeAuth (Xauth *auth) free (auth->number); free (auth->name); if (auth->data) { +#ifdef HAVE_EXPLICIT_BZERO + (void) explicit_bzero (auth->data, auth->data_length); +#else (void) bzero (auth->data, auth->data_length); +#endif (void) free (auth->data); } free ((char *) auth); @@ -56,7 +56,11 @@ read_counted_string (unsigned short *countp, char **stringp, FILE *file) if (!data) return 0; if (fread (data, sizeof (char), len, file) != len) { +#ifdef HAVE_EXPLICIT_BZERO + explicit_bzero (data, len); +#else bzero (data, len); +#endif free (data); return 0; } @@ -97,7 +101,11 @@ XauReadAuth (FILE *auth_file) free (local.number); free (local.name); if (local.data) { +#ifdef HAVE_EXPLICIT_BZERO + explicit_bzero (local.data, local.data_length); +#else bzero (local.data, local.data_length); +#endif free (local.data); } return NULL; diff --git a/configure.ac b/configure.ac index cc38e7f..47316ce 100644 --- a/configure.ac +++ b/configure.ac @@ -45,7 +45,7 @@ XORG_DEFAULT_OPTIONS AC_PROG_LN_S # Checks for library functions. -AC_CHECK_FUNCS([pathconf]) +AC_CHECK_FUNCS([explicit_bzero pathconf]) # Obtain compiler/linker options for depedencies PKG_CHECK_MODULES(XAU, xproto) |