summaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
authorDenys Vlasenko2013-11-19 13:36:45 +0100
committerDenys Vlasenko2013-11-19 13:36:45 +0100
commit8b59b2c13ededb2c82e36193b6d6e969df36531c (patch)
tree7b5065279d3c5a6c8bd0ca90584d49bb73aac01c /libbb
parent6ef77291122d231754e7292630681dc67c109d60 (diff)
downloadbusybox-8b59b2c13ededb2c82e36193b6d6e969df36531c.zip
busybox-8b59b2c13ededb2c82e36193b6d6e969df36531c.tar.gz
libbb: move nuke_str() from passwd into libbb
function old new delta nuke_str - 15 +15 ask_and_check_password_extended 215 206 -9 init_main 781 771 -10 nuke_str 27 - -27 ------------------------------------------------------------------------------ (add/remove: 1/1 grow/shrink: 0/2 up/down: 15/-46) Total: -31 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'libbb')
-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 d39a583..5727c65 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;
}