summaryrefslogtreecommitdiffstats
path: root/src/util/util.c
diff options
context:
space:
mode:
authorSimo Sorce <simo@redhat.com>2012-10-20 01:10:20 -0400
committerSimo Sorce <simo@redhat.com>2013-01-10 12:24:59 -0500
commitc63415eabb1dc595c60760fb1df7fa7cfd1d3200 (patch)
treee169d1edc152cbbe0a3b25a22fb9e3f46f7bb7b1 /src/util/util.c
parentc83e409297711e6012a164cc929c758a3f38e9b9 (diff)
downloadsssd-c63415eabb1dc595c60760fb1df7fa7cfd1d3200.tar.gz
sssd-c63415eabb1dc595c60760fb1df7fa7cfd1d3200.tar.xz
sssd-c63415eabb1dc595c60760fb1df7fa7cfd1d3200.zip
Add function to safely wipe memory.
This is useful for wiping passwords, as it prevents the compiler from optimizing out a memset to zero before a free()
Diffstat (limited to 'src/util/util.c')
-rw-r--r--src/util/util.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/util/util.c b/src/util/util.c
index b035e2319..ba85e0da2 100644
--- a/src/util/util.c
+++ b/src/util/util.c
@@ -679,3 +679,12 @@ bool string_in_list(const char *string, char **list, bool case_sensitive)
return false;
}
+
+void safezero(void *data, size_t size)
+{
+ volatile uint8_t *p = data;
+
+ while (size--) {
+ *p++ = 0;
+ }
+}