]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
Remove string_erase
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 10 Jul 2019 11:54:50 +0000 (13:54 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 10 Jul 2019 12:43:44 +0000 (14:43 +0200)
TODO
src/basic/string-util.c
src/basic/string-util.h
src/basic/strv.c
src/journal/journalctl.c
src/test/test-string-util.c

diff --git a/TODO b/TODO
index 6331c9bd2ea25011f9a40d22f7bc0006b96df55a..35f711eaff27b9f4af028134a0302e3389d8c74e 100644 (file)
--- a/TODO
+++ b/TODO
@@ -90,7 +90,7 @@ Features:
   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
index 08a10e8787964b1a6e8e83f6dc4f5eb3ab4ba4dd..474903b2a87b0b96496efd1fe7263edd018b0810 100644 (file)
@@ -1032,16 +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;
-}
-
 bool string_is_safe(const char *p) {
         const char *t;
 
index 5ad78be1d3abffa5d5d799146eb405ee3e5c5933..ef136da49e02bfaf89c7d7d7195628a92b980467 100644 (file)
@@ -197,8 +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);
-
 bool string_is_safe(const char *p) _pure_;
 
 static inline size_t strlen_ptr(const char *s) {
index 21c106149b219910cf5b2dd07b20aecdcc0d9e96..0a1adbf30bd7a0c3d5c801b196019c2105af90ba 100644 (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) {
index 27518b636342e17847218156df2bb7ed98d5939b..2a82c241a5f560d2c5a5623988ea53f148e5a448 100644 (file)
@@ -753,7 +753,7 @@ static int parse_argv(int argc, char *argv[]) {
                         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));
 
index f7dde618d3e011a55b9ad64b3fb146096d174f89..d84170bc22231cec0c7f3107bc90742cd9314d68 100644 (file)
@@ -9,29 +9,6 @@
 #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;
 
@@ -582,7 +559,6 @@ static void test_memory_startswith_no_case(void) {
 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();