bzero(3) - OpenBSD manual pages (original) (raw)

NAME

bzero,explicit_bzero —write zeroes to a byte string

SYNOPSIS

#include <strings.h>

void
bzero(void *b, size_t len);

#include <string.h>

void
explicit_bzero(void *b, size_t len);

DESCRIPTION

Thebzero() function writes len zero bytes to the stringb. If len is zero,bzero() does nothing.

Theexplicit_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.

SEE ALSO

memset(3), swab(3)

STANDARDS

The bzero() function conforms to the X/Open System Interfaces option of the IEEE Std 1003.1-2004 (“POSIX.1”) specification. It was removed from the standard in IEEE Std 1003.1-2008 (“POSIX.1”), which recommends usingmemset(3) instead.

The explicit_bzero() function is anOpenBSD extension.

HISTORY

The bzero() function first appeared in4.2BSD. The explicit_bzero() function first appeared in OpenBSD 5.5.