aboutsummaryrefslogtreecommitdiff
path: root/libbb/correct_password.c
diff options
context:
space:
mode:
Diffstat (limited to 'libbb/correct_password.c')
-rw-r--r--libbb/correct_password.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/libbb/correct_password.c b/libbb/correct_password.c
index d39a5839c..5727c65fb 100644
--- a/libbb/correct_password.c
+++ b/libbb/correct_password.c
@@ -30,6 +30,15 @@
#include "libbb.h"
+void FAST_FUNC nuke_str(char *str)
+{
+ if (str) {
+ while (*str)
+ *str++ = 0;
+ /* or: memset(str, 0, strlen(str)); - not as small as above */
+ }
+}
+
/* Ask the user for a password.
* Return 1 without asking if PW has an empty password.
* Return -1 on EOF, error while reading input, or timeout.
@@ -76,7 +85,7 @@ int FAST_FUNC ask_and_check_password_extended(const struct passwd *pw,
encrypted = pw_encrypt(unencrypted, correct, 1);
r = (strcmp(encrypted, correct) == 0);
free(encrypted);
- memset(unencrypted, 0, strlen(unencrypted));
+ nuke_str(unencrypted);
return r;
}