summaryrefslogtreecommitdiffstats
path: root/lib/libc/string/bzero.3
diff options
context:
space:
mode:
authortedu <tedu@openbsd.org>2014-01-22 21:06:45 +0000
committertedu <tedu@openbsd.org>2014-01-22 21:06:45 +0000
commit2fa321beb47f73cfed1daedbabd3f5ea94c00670 (patch)
treeb87d0f493b7b171de2fad7bced75d1905ef78106 /lib/libc/string/bzero.3
parentImplement the \: (optional line break) escape sequence, (diff)
downloadwireguard-openbsd-2fa321beb47f73cfed1daedbabd3f5ea94c00670.tar.xz
wireguard-openbsd-2fa321beb47f73cfed1daedbabd3f5ea94c00670.zip
add explicit_bzero to libc. implementation subject to change, but start
the ball rolling. ok deraadt.
Diffstat (limited to 'lib/libc/string/bzero.3')
-rw-r--r--lib/libc/string/bzero.316
1 files changed, 14 insertions, 2 deletions
diff --git a/lib/libc/string/bzero.3 b/lib/libc/string/bzero.3
index 1fd5da81b5c..8476eb863e4 100644
--- a/lib/libc/string/bzero.3
+++ b/lib/libc/string/bzero.3
@@ -27,9 +27,9 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $OpenBSD: bzero.3,v 1.9 2013/06/05 03:39:23 tedu Exp $
+.\" $OpenBSD: bzero.3,v 1.10 2014/01/22 21:06:45 tedu Exp $
.\"
-.Dd $Mdocdate: June 5 2013 $
+.Dd $Mdocdate: January 22 2014 $
.Dt BZERO 3
.Os
.Sh NAME
@@ -39,6 +39,8 @@
.In string.h
.Ft void
.Fn bzero "void *b" "size_t len"
+.Ft void
+.Fn explicit_bzero "void *b" "size_t len"
.Sh DESCRIPTION
The
.Fn bzero
@@ -51,6 +53,12 @@ If
is zero,
.Fn bzero
does nothing.
+.Pp
+The
+.Fn explicit_bzero
+variant behaves the same, but will not be removed by a compiler's dead store
+optimization pass, making it useful for clearing sensitive memory such as a
+password.
.Sh SEE ALSO
.Xr memset 3 ,
.Xr swab 3
@@ -59,3 +67,7 @@ The
.Fn bzero
function first appeared in
.Bx 4.2 .
+The
+.Fn explicit_bzero
+function first appeared in
+.Ox 5.5 .