[PATCH 2/5] Add explicit_bzero()

Corinna Vinschen vinschen@redhat.com
Fri Mar 18 11:24:00 GMT 2016


On Mar 18 11:49, Sebastian Huber wrote:
> This function is used by LibreSSL and OpenSSH and is provided by the
> OpenBSD libc.
> [...]
> +#include <string.h>
> +
> +/*
> + * explicit_bzero - don't let the compiler optimize away bzero
> + */
> +void
> +explicit_bzero(void *p, size_t n)
> +{
> +	bzero(p, n);
> +}

The OpenSSH version looks a bit different:

  /*
   * Indirect bzero through a volatile pointer to hopefully avoid
   * dead-store optimisation eliminating the call.
   */
  static void (* volatile ssh_bzero)(void *, size_t) = bzero;

  void
  explicit_bzero(void *p, size_t n)
  {
	  ssh_bzero(p, n);
  }

Is that something we should do, too, or is that paranoia at its
finest only?


Thanks,
Corinna

-- 
Corinna Vinschen
Cygwin Maintainer
Red Hat
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/newlib/attachments/20160318/e420b2f6/attachment.sig>


More information about the Newlib mailing list