diff options
author | Lennart Poettering <lennart@poettering.net> | 2019-03-20 10:29:20 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2019-03-20 10:48:33 +0100 |
commit | e1ed99c8c89d6e4ca4df3e47617ff1f3e194cabb (patch) | |
tree | d01ff5dcd5ead9109962b7a0f81e1f942e27bfa8 /src/basic/memory-util.h | |
parent | d5d1ae153f394aa08e436a747d20702b18e79f00 (diff) | |
download | systemd-e1ed99c8c89d6e4ca4df3e47617ff1f3e194cabb.tar.gz |
ask-password: erase character read with _cleanup_
This is much nicer, since it means we erase the character regardless how
we exit the scope.
Diffstat (limited to 'src/basic/memory-util.h')
-rw-r--r-- | src/basic/memory-util.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/basic/memory-util.h b/src/basic/memory-util.h index e1e6624d3b..915c24a5dd 100644 --- a/src/basic/memory-util.h +++ b/src/basic/memory-util.h @@ -77,3 +77,8 @@ static inline void* explicit_bzero_safe(void *p, size_t l) { #else void *explicit_bzero_safe(void *p, size_t l); #endif + +/* Use with _cleanup_ to erase a single 'char' when leaving scope */ +static inline void erase_char(char *p) { + explicit_bzero_safe(p, sizeof(char)); +} |