logo

oasis

Own branch of Oasis Linux (upstream: <https://git.sr.ht/~mcf/oasis/>) git clone https://anongit.hacktivis.me/git/oasis.git

0016-Add-standalone-freezero.patch (1725B)


  1. From 98a3b77cfa775c87010159d49f5b17d84fe1aa7b Mon Sep 17 00:00:00 2001
  2. From: Michael Forney <mforney@mforney.org>
  3. Date: Tue, 10 Oct 2017 03:07:56 -0700
  4. Subject: [PATCH] Add standalone freezero
  5. ---
  6. lib/libc/stdlib/freezero.c | 32 ++++++++++++++++++++++++++++++++
  7. 1 file changed, 32 insertions(+)
  8. create mode 100644 lib/libc/stdlib/freezero.c
  9. diff --git a/lib/libc/stdlib/freezero.c b/lib/libc/stdlib/freezero.c
  10. new file mode 100644
  11. index 00000000000..31face3828b
  12. --- /dev/null
  13. +++ b/lib/libc/stdlib/freezero.c
  14. @@ -0,0 +1,32 @@
  15. +/*
  16. + * Copyright (c) 2008, 2010, 2011, 2016 Otto Moerbeek <otto@drijf.net>
  17. + * Copyright (c) 2012 Matthew Dempsky <matthew@openbsd.org>
  18. + * Copyright (c) 2008 Damien Miller <djm@openbsd.org>
  19. + * Copyright (c) 2000 Poul-Henning Kamp <phk@FreeBSD.org>
  20. + *
  21. + * Permission to use, copy, modify, and distribute this software for any
  22. + * purpose with or without fee is hereby granted, provided that the above
  23. + * copyright notice and this permission notice appear in all copies.
  24. + *
  25. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  26. + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  27. + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  28. + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  29. + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  30. + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  31. + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  32. + */
  33. +
  34. +#include <string.h>
  35. +#include <stdlib.h>
  36. +
  37. +void
  38. +freezero(void *ptr, size_t sz)
  39. +{
  40. + /* This is legal. */
  41. + if (ptr == NULL)
  42. + return;
  43. +
  44. + explicit_bzero(ptr, sz);
  45. + free(ptr);
  46. +}
  47. --
  48. 2.14.2