DragonFly On-Line Manual Pages

Search: Section:  


PWS_STR_MEMNUKE(3)    DragonFly Library Functions Manual    PWS_STR_MEMNUKE(3)

NAME

pws_str_memnuke - Over-write the contents of a memory buffer with zeros

LIBRARY

-lpwstor

SYNOPSIS

#include <pwstor.h> void pws_str_memnuke(volatile void *b, size_t sz);

DESCRIPTION

The function pws_str_memnuke() will over-write sz bytes of memory from the pointer referenced by b with zeros. This is useful for clearing a memory buffer which contained, for example, a clear-text password. Calls to free() do not zero the memory, so another application could conceivably allocate memory which contains sensitive data from another application. Calling pws_str_memnuke() on the buffer prior to calling free() on it will prevent this potentially dangerous condition.

CAVEATS

The pws_str_memnuke() function cannot indicate an error, for example if it returns prematurely because a null-pointer was passed to it. It requires that b be cast (volatile) in order to prevent compilers from optimizing it out so that memory is safely wiped.

SEE ALSO

pwstor(3) DragonFly 6.5-DEVELOPMENT October 23, 2008 DragonFly 6.5-DEVELOPMENT

Search: Section: