Merge pull request #13011 from keszybz/auto-erase

Remove string_erase and friends
This commit is contained in:
Lennart Poettering
2019-07-11 01:05:01 +02:00
committed by GitHub
9 changed files with 18 additions and 60 deletions
-14
View File
@@ -1032,20 +1032,6 @@ int free_and_strndup(char **p, const char *s, size_t l) {
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;
}
char *string_free_erase(char *s) {
return mfree(string_erase(s));
}
bool string_is_safe(const char *p) {
const char *t;
-6
View File
@@ -197,12 +197,6 @@ static inline int free_and_strdup_warn(char **p, const char *s) {
}
int free_and_strndup(char **p, const char *s, size_t l);
char *string_erase(char *x);
char *string_free_erase(char *s);
DEFINE_TRIVIAL_CLEANUP_FUNC(char *, string_free_erase);
#define _cleanup_string_free_erase_ _cleanup_(string_free_erasep)
bool string_is_safe(const char *p) _pure_;
static inline size_t strlen_ptr(const char *s) {
+3 -2
View File
@@ -11,6 +11,7 @@
#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"
@@ -78,9 +79,9 @@ char **strv_free_erase(char **l) {
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) {