usefaultd() and make systemd-analyze check for it.
* paranoia: whenever we process passwords, call mlock() on the memory
- first. i.e. look for all places we use string_erase()/free_and_erasep() and
+ first. i.e. look for all places we use free_and_erasep() and
augment them with mlock(). Also use MADV_DONTDUMP.
* Move RestrictAddressFamily= to the new cgroup create socket
return 1;
}
-char* string_erase(char *x) {
- if (!x)
- return NULL;
-
- /* A delicious drop of snake-oil! To be called on memory where
- * we stored passphrases or so, after we used them. */
- explicit_bzero_safe(x, strlen(x));
- return x;
-}
-
bool string_is_safe(const char *p) {
const char *t;
}
int free_and_strndup(char **p, const char *s, size_t l);
-char *string_erase(char *x);
-
bool string_is_safe(const char *p) _pure_;
static inline size_t strlen_ptr(const char *s) {
#include "escape.h"
#include "extract-word.h"
#include "fileio.h"
+#include "memory-util.h"
#include "nulstr-util.h"
#include "sort-util.h"
#include "string-util.h"
char **i;
STRV_FOREACH(i, l)
- string_erase(*i);
+ erase_and_freep(i);
- return strv_free(l);
+ return mfree(l);
}
char **strv_copy(char * const *l) {
r = free_and_strdup(&arg_verify_key, optarg);
if (r < 0)
return r;
- /* Use memset not string_erase so this doesn't look confusing
+ /* Use memset not explicit_bzero() or similar so this doesn't look confusing
* in ps or htop output. */
memset(optarg, 'x', strlen(optarg));
#include "utf8.h"
#include "util.h"
-static void test_string_erase(void) {
- char *x;
-
- x = strdupa("");
- assert_se(streq(string_erase(x), ""));
-
- x = strdupa("1");
- assert_se(streq(string_erase(x), ""));
-
- x = strdupa("123456789");
- assert_se(streq(string_erase(x), ""));
-
- assert_se(x[1] == '\0');
- assert_se(x[2] == '\0');
- assert_se(x[3] == '\0');
- assert_se(x[4] == '\0');
- assert_se(x[5] == '\0');
- assert_se(x[6] == '\0');
- assert_se(x[7] == '\0');
- assert_se(x[8] == '\0');
- assert_se(x[9] == '\0');
-}
-
static void test_free_and_strndup_one(char **t, const char *src, size_t l, const char *expected, bool change) {
int r;
int main(int argc, char *argv[]) {
test_setup_logging(LOG_DEBUG);
- test_string_erase();
test_free_and_strndup();
test_ascii_strcasecmp_n();
test_ascii_strcasecmp_nn();