diff options
author | Simo Sorce <simo@redhat.com> | 2014-01-04 15:13:23 -0500 |
---|---|---|
committer | Simo Sorce <simo@redhat.com> | 2014-01-05 00:33:21 -0500 |
commit | 9dc58213070eb4cb459ae31134840dcf098cc1b0 (patch) | |
tree | 7b73f04081e52159c443179de451abd43e004330 | |
parent | e711c6b042040b1317f99bcd2c9b22355ceab7b8 (diff) | |
download | gss-proxy-9dc58213070eb4cb459ae31134840dcf098cc1b0.tar.gz gss-proxy-9dc58213070eb4cb459ae31134840dcf098cc1b0.tar.xz gss-proxy-9dc58213070eb4cb459ae31134840dcf098cc1b0.zip |
Add function to safely zero out secrets
Signed-off-by: Simo Sorce <simo@redhat.com>
-rw-r--r-- | proxy/src/gp_common.h | 2 | ||||
-rw-r--r-- | proxy/src/gp_util.c | 10 |
2 files changed, 12 insertions, 0 deletions
diff --git a/proxy/src/gp_common.h b/proxy/src/gp_common.h index 3a1b7be..7b3e9ac 100644 --- a/proxy/src/gp_common.h +++ b/proxy/src/gp_common.h @@ -71,6 +71,8 @@ char *gp_getenv(const char *name); ssize_t gp_safe_read(int fd, void *buf, size_t count); ssize_t gp_safe_write(int fd, const void *buf, size_t count); +void gp_safe_zero(void *buf, size_t len); + /* NOTE: read the note in gp_util.c before using gp_strerror() */ char *gp_strerror(int errnum); diff --git a/proxy/src/gp_util.c b/proxy/src/gp_util.c index 34f3024..a60779b 100644 --- a/proxy/src/gp_util.c +++ b/proxy/src/gp_util.c @@ -25,6 +25,7 @@ #include "config.h" #include <stdbool.h> +#include <stdint.h> #include <string.h> #include <stdlib.h> #include <stdio.h> @@ -164,3 +165,12 @@ ssize_t gp_safe_write(int fd, const void *buf, size_t count) return len; } + +void gp_safe_zero(void *buf, size_t len) +{ + volatile uint8_t *p = buf; + + while (len--) { + *p++ = 0; + } +} |