From: Nathan McSween <nwmcsween@gmail.com>
To: musl@lists.openwall.com
Cc: Nathan McSween <nwmcsween@gmail.com>
Subject: [RFC PATCH 5/5] string: add memsset a 'secure' memset and bsd explicit_bzero
Date: Sat, 15 Jul 2017 19:55:41 +0000 [thread overview]
Message-ID: <20170715195541.3136-6-nwmcsween@gmail.com> (raw)
In-Reply-To: <20170715195541.3136-1-nwmcsween@gmail.com>
---
src/string/explicit_bzero.c | 9 +++++++++
src/string/memsset.c | 13 +++++++++++++
2 files changed, 22 insertions(+)
create mode 100644 src/string/explicit_bzero.c
create mode 100644 src/string/memsset.c
diff --git a/src/string/explicit_bzero.c b/src/string/explicit_bzero.c
new file mode 100644
index 00000000..497dd2bc
--- /dev/null
+++ b/src/string/explicit_bzero.c
@@ -0,0 +1,9 @@
+#define _BSD_SOURCE
+#include <string.h>
+
+void *__memsset(void *, int, size_t);
+
+void explicit_bzero(void *d, size_t n)
+{
+ __memsset(d, 0, n);
+}
diff --git a/src/string/memsset.c b/src/string/memsset.c
new file mode 100644
index 00000000..d4ab72a4
--- /dev/null
+++ b/src/string/memsset.c
@@ -0,0 +1,13 @@
+#include <string.h>
+
+#define hidden __attribute__((visibility("hidden")))
+
+hidden
+void *__memsset(void *d, int i, size_t n)
+{
+ memset(d, i, n);
+
+ __asm__ __volatile__("" : "=r" (d): "0" (d) : "memory");
+
+ return d;
+}
--
2.13.2
prev parent reply other threads:[~2017-07-15 19:55 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-15 19:55 [RFC PATCH 0/5] Add explicit_bzero, vectorize and 'normalize' various string functions Nathan McSween
2017-07-15 19:55 ` [RFC PATCH 1/5] string: vectorize various functions Nathan McSween
2017-07-15 19:55 ` [RFC PATCH 2/5] string: modify wordwise functions to match new style Nathan McSween
2017-07-15 19:55 ` [RFC PATCH 3/5] string: add strscpy and modify functions to use strscpy Nathan McSween
2017-07-15 19:55 ` [RFC PATCH 4/5] string: use strchrnul in strcasestr instead of bytewise iteration Nathan McSween
2017-07-15 19:55 ` Nathan McSween [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170715195541.3136-6-nwmcsween@gmail.com \
--to=nwmcsween@gmail.com \
--cc=musl@lists.openwall.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).