diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2007-06-18 10:35:06 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2007-06-18 10:35:06 +0000 |
commit | 91e149a3736ddc357950252c02d758515074447f (patch) | |
tree | 3f91621bb8958873a71699d8eb018838251e8c17 | |
parent | 2c91efb7c24da6370810991459ae360029022250 (diff) | |
download | busybox-w32-91e149a3736ddc357950252c02d758515074447f.tar.gz busybox-w32-91e149a3736ddc357950252c02d758515074447f.tar.bz2 busybox-w32-91e149a3736ddc357950252c02d758515074447f.zip |
libbb: random hunt for statics
function old new delta
bb_askpass 306 321 +15
pw_encrypt 38 39 +1
static.passwd 64 4 -60
static.cipher 128 4 -124
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/2 up/down: 16/-184) Total: -168 bytes
# size busybox_old busybox_unstripped
text data bss dec hex filename
683705 2704 14240 700649 ab0e9 busybox_old
683721 2704 14064 700489 ab049 busybox_unstripped
-rw-r--r-- | libbb/bb_askpass.c | 17 | ||||
-rw-r--r-- | libbb/pw_encrypt.c | 12 |
2 files changed, 16 insertions, 13 deletions
diff --git a/libbb/bb_askpass.c b/libbb/bb_askpass.c index 0f1f68687..5ad234921 100644 --- a/libbb/bb_askpass.c +++ b/libbb/bb_askpass.c | |||
@@ -9,7 +9,6 @@ | |||
9 | */ | 9 | */ |
10 | 10 | ||
11 | #include <termios.h> | 11 | #include <termios.h> |
12 | //#include <sys/ioctl.h> | ||
13 | 12 | ||
14 | #include "libbb.h" | 13 | #include "libbb.h" |
15 | 14 | ||
@@ -20,18 +19,22 @@ static void askpass_timeout(int ATTRIBUTE_UNUSED ignore) | |||
20 | 19 | ||
21 | char *bb_askpass(int timeout, const char * prompt) | 20 | char *bb_askpass(int timeout, const char * prompt) |
22 | { | 21 | { |
23 | static char passwd[64]; | 22 | /* Was static char[BIGNUM] */ |
23 | enum { sizeof_passwd = 128 }; | ||
24 | static char *passwd; | ||
24 | 25 | ||
25 | char *ret; | 26 | char *ret; |
26 | int i; | 27 | int i; |
27 | struct sigaction sa; | 28 | struct sigaction sa; |
28 | struct termios old, new; | 29 | struct termios old, new; |
29 | 30 | ||
31 | if (!passwd) | ||
32 | passwd = xmalloc(sizeof_passwd); | ||
33 | memset(passwd, 0, sizeof_passwd); | ||
34 | |||
30 | tcgetattr(STDIN_FILENO, &old); | 35 | tcgetattr(STDIN_FILENO, &old); |
31 | tcflush(STDIN_FILENO, TCIFLUSH); | 36 | tcflush(STDIN_FILENO, TCIFLUSH); |
32 | 37 | ||
33 | memset(passwd, 0, sizeof(passwd)); | ||
34 | |||
35 | fputs(prompt, stdout); | 38 | fputs(prompt, stdout); |
36 | fflush(stdout); | 39 | fflush(stdout); |
37 | 40 | ||
@@ -48,7 +51,9 @@ char *bb_askpass(int timeout, const char * prompt) | |||
48 | } | 51 | } |
49 | 52 | ||
50 | ret = NULL; | 53 | ret = NULL; |
51 | if (read(STDIN_FILENO, passwd, sizeof(passwd)-1) > 0) { | 54 | /* On timeout, read will hopefully be interrupted by SIGALRM, |
55 | * and we return NULL */ | ||
56 | if (read(STDIN_FILENO, passwd, sizeof_passwd-1) > 0) { | ||
52 | ret = passwd; | 57 | ret = passwd; |
53 | i = 0; | 58 | i = 0; |
54 | /* Last byte is guaranteed to be 0 | 59 | /* Last byte is guaranteed to be 0 |
@@ -64,7 +69,7 @@ char *bb_askpass(int timeout, const char * prompt) | |||
64 | } | 69 | } |
65 | 70 | ||
66 | tcsetattr(STDIN_FILENO, TCSANOW, &old); | 71 | tcsetattr(STDIN_FILENO, TCSANOW, &old); |
67 | puts(""); | 72 | putchar('\n'); |
68 | fflush(stdout); | 73 | fflush(stdout); |
69 | return ret; | 74 | return ret; |
70 | } | 75 | } |
diff --git a/libbb/pw_encrypt.c b/libbb/pw_encrypt.c index d546bc883..e9cf4e3b8 100644 --- a/libbb/pw_encrypt.c +++ b/libbb/pw_encrypt.c | |||
@@ -12,18 +12,16 @@ | |||
12 | 12 | ||
13 | char *pw_encrypt(const char *clear, const char *salt) | 13 | char *pw_encrypt(const char *clear, const char *salt) |
14 | { | 14 | { |
15 | static char cipher[128]; | 15 | /* Was static char[BIGNUM]. Malloced thing works as well */ |
16 | char *cp; | 16 | static char *cipher; |
17 | 17 | ||
18 | #if 0 /* was CONFIG_FEATURE_SHA1_PASSWORDS, but there is no such thing??? */ | 18 | #if 0 /* was CONFIG_FEATURE_SHA1_PASSWORDS, but there is no such thing??? */ |
19 | if (strncmp(salt, "$2$", 3) == 0) { | 19 | if (strncmp(salt, "$2$", 3) == 0) { |
20 | return sha1_crypt(clear); | 20 | return sha1_crypt(clear); |
21 | } | 21 | } |
22 | #endif | 22 | #endif |
23 | cp = (char *) crypt(clear, salt); | 23 | |
24 | /* if crypt (a nonstandard crypt) returns a string too large, | 24 | free(cipher); |
25 | truncate it so we don't overrun buffers and hope there is | 25 | cipher = xstrdup(crypt(clear, salt)); |
26 | enough security in what's left */ | ||
27 | safe_strncpy(cipher, cp, sizeof(cipher)); | ||
28 | return cipher; | 26 | return cipher; |
29 | } | 27 | } |