diff options
| author | Mattias Andrée <m@maandree.se> | 2026-04-26 22:36:47 +0200 |
|---|---|---|
| committer | Mattias Andrée <m@maandree.se> | 2026-04-26 22:36:47 +0200 |
| commit | d77ab463184d113ca6119403887c9f4ed0dfdf0b (patch) | |
| tree | ca8a1de443f90a4b7def56ea5b61c96aaa949f45 /librecrypt_wipe_str.c | |
| download | librecrypt-d77ab463184d113ca6119403887c9f4ed0dfdf0b.tar.gz librecrypt-d77ab463184d113ca6119403887c9f4ed0dfdf0b.tar.bz2 librecrypt-d77ab463184d113ca6119403887c9f4ed0dfdf0b.tar.xz | |
First commit
Signed-off-by: Mattias Andrée <m@maandree.se>
Diffstat (limited to '')
| -rw-r--r-- | librecrypt_wipe_str.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/librecrypt_wipe_str.c b/librecrypt_wipe_str.c new file mode 100644 index 0000000..8c31cdc --- /dev/null +++ b/librecrypt_wipe_str.c @@ -0,0 +1,39 @@ +/* See LICENSE file for copyright and license details. */ +#include "common.h" +#ifndef TEST + + +extern inline void librecrypt_wipe_str(char *string); + + +#else + + +#define CHECK(TEXT)\ + do {\ + memset(buf, 0, sizeof(buf));\ + stpcpy(buf, (TEXT));\ + assert(!strcmp(buf, (TEXT)));\ + librecrypt_wipe_str(buf);\ + for (i = 0u; i < sizeof(buf); i++)\ + EXPECT(!buf[i]);\ + } while (0) + + +int +main(void) +{ + char buf[64u]; + size_t i; + SET_UP_ALARM(); + librecrypt_wipe_str(NULL); + CHECK(""); + CHECK("hello"); + CHECK("hello developer"); + CHECK(" hello developer "); + CHECK("\1 hello developer \1"); + return 0; +} + + +#endif |
