diff options
| author | Eric Andersen <andersen@codepoet.org> | 2002-10-10 04:20:21 +0000 |
|---|---|---|
| committer | Eric Andersen <andersen@codepoet.org> | 2002-10-10 04:20:21 +0000 |
| commit | 71ae64bdc6b044eef0a9f3bebd85cc4a6b67362f (patch) | |
| tree | 802990cf39a805f253b9d32f3888a7c749babd01 /libbb | |
| parent | fdfe298a966da0e6eecdc355efd640acf73c00e5 (diff) | |
| download | busybox-w32-71ae64bdc6b044eef0a9f3bebd85cc4a6b67362f.tar.gz busybox-w32-71ae64bdc6b044eef0a9f3bebd85cc4a6b67362f.tar.bz2 busybox-w32-71ae64bdc6b044eef0a9f3bebd85cc4a6b67362f.zip | |
last_patch61 from vodz:
New complex patch for decrease size devel version. Requires previous patch.
Also removed small problems from dutmp and tar applets.
Also includes vodz' last_patch61_2:
Last patch correcting comment for #endif and more integrated
with libbb (very reduce size if used "cat" applet also).
Requires last_patch61 for modutils/config.in.
Diffstat (limited to 'libbb')
| -rw-r--r-- | libbb/messages.c | 2 | ||||
| -rw-r--r-- | libbb/obscure.c | 62 |
2 files changed, 33 insertions, 31 deletions
diff --git a/libbb/messages.c b/libbb/messages.c index 185c1ee91..cc7e2146c 100644 --- a/libbb/messages.c +++ b/libbb/messages.c | |||
| @@ -45,7 +45,7 @@ | |||
| 45 | const char * const invalid_option = "invalid option -- %c"; | 45 | const char * const invalid_option = "invalid option -- %c"; |
| 46 | #endif | 46 | #endif |
| 47 | #ifdef L_io_error | 47 | #ifdef L_io_error |
| 48 | const char * const io_error = "%s: input/output error -- %s"; | 48 | const char * const io_error = "%s: input/output error -- %m"; |
| 49 | #endif | 49 | #endif |
| 50 | #ifdef L_dash_dash_help | 50 | #ifdef L_dash_dash_help |
| 51 | const char * const dash_dash_help = "--help"; | 51 | const char * const dash_dash_help = "--help"; |
diff --git a/libbb/obscure.c b/libbb/obscure.c index dc7de751d..588ef5af6 100644 --- a/libbb/obscure.c +++ b/libbb/obscure.c | |||
| @@ -44,7 +44,7 @@ | |||
| 44 | * can't be a palindrome - like `R A D A R' or `M A D A M' | 44 | * can't be a palindrome - like `R A D A R' or `M A D A M' |
| 45 | */ | 45 | */ |
| 46 | 46 | ||
| 47 | static int palindrome(const char *old, const char *newval) | 47 | static int palindrome(const char *newval) |
| 48 | { | 48 | { |
| 49 | int i, j; | 49 | int i, j; |
| 50 | 50 | ||
| @@ -79,24 +79,25 @@ static int similiar(const char *old, const char *newval) | |||
| 79 | * a nice mix of characters. | 79 | * a nice mix of characters. |
| 80 | */ | 80 | */ |
| 81 | 81 | ||
| 82 | static int simple(const char *old, const char *newval) | 82 | static int simple(const char *newval) |
| 83 | { | 83 | { |
| 84 | int digits = 0; | 84 | int digits = 0; |
| 85 | int uppers = 0; | 85 | int uppers = 0; |
| 86 | int lowers = 0; | 86 | int lowers = 0; |
| 87 | int others = 0; | 87 | int others = 0; |
| 88 | int c; | ||
| 88 | int size; | 89 | int size; |
| 89 | int i; | 90 | int i; |
| 90 | 91 | ||
| 91 | for (i = 0; newval[i]; i++) { | 92 | for (i = 0; (c = *newval++) != 0; i++) { |
| 92 | if (isdigit(newval[i])) | 93 | if (isdigit(c)) |
| 93 | digits++; | 94 | digits = c; |
| 94 | else if (isupper(newval[i])) | 95 | else if (isupper(c)) |
| 95 | uppers++; | 96 | uppers = c; |
| 96 | else if (islower(newval[i])) | 97 | else if (islower(c)) |
| 97 | lowers++; | 98 | lowers = c; |
| 98 | else | 99 | else |
| 99 | others++; | 100 | others = c; |
| 100 | } | 101 | } |
| 101 | 102 | ||
| 102 | /* | 103 | /* |
| @@ -129,49 +130,50 @@ static char *str_lower(char *string) | |||
| 129 | return string; | 130 | return string; |
| 130 | } | 131 | } |
| 131 | 132 | ||
| 132 | static char *password_check(const char *old, const char *newval, const struct passwd *pwdp) | 133 | static const char * |
| 134 | password_check(const char *old, const char *newval, const struct passwd *pwdp) | ||
| 133 | { | 135 | { |
| 134 | char *msg = NULL; | 136 | const char *msg; |
| 135 | char *oldmono, *newmono, *wrapped; | 137 | char *newmono, *wrapped; |
| 138 | int lenwrap; | ||
| 136 | 139 | ||
| 137 | if (strcmp(newval, old) == 0) | 140 | if (strcmp(newval, old) == 0) |
| 138 | return "no change"; | 141 | return "no change"; |
| 142 | if (simple(newval)) | ||
| 143 | return "too simple"; | ||
| 139 | 144 | ||
| 145 | msg = NULL; | ||
| 140 | newmono = str_lower(xstrdup(newval)); | 146 | newmono = str_lower(xstrdup(newval)); |
| 141 | oldmono = str_lower(xstrdup(old)); | 147 | lenwrap = strlen(old) * 2 + 1; |
| 142 | wrapped = (char *) xmalloc(strlen(oldmono) * 2 + 1); | 148 | wrapped = (char *) xmalloc(lenwrap); |
| 143 | strcpy(wrapped, oldmono); | 149 | str_lower(strcpy(wrapped, old)); |
| 144 | strcat(wrapped, oldmono); | ||
| 145 | 150 | ||
| 146 | if (palindrome(oldmono, newmono)) | 151 | if (palindrome(newmono)) |
| 147 | msg = "a palindrome"; | 152 | msg = "a palindrome"; |
| 148 | 153 | ||
| 149 | if (!msg && strcmp(oldmono, newmono) == 0) | 154 | else if (strcmp(wrapped, newmono) == 0) |
| 150 | msg = "case changes only"; | 155 | msg = "case changes only"; |
| 151 | 156 | ||
| 152 | if (!msg && similiar(oldmono, newmono)) | 157 | else if (similiar(wrapped, newmono)) |
| 153 | msg = "too similiar"; | 158 | msg = "too similiar"; |
| 154 | 159 | ||
| 155 | if (!msg && simple(old, newval)) | 160 | else if (strstr(strcat(wrapped, wrapped), newmono)) |
| 156 | msg = "too simple"; | ||
| 157 | |||
| 158 | if (!msg && strstr(wrapped, newmono)) | ||
| 159 | msg = "rotated"; | 161 | msg = "rotated"; |
| 160 | 162 | ||
| 161 | bzero(newmono, strlen(newmono)); | 163 | bzero(newmono, strlen(newmono)); |
| 162 | bzero(oldmono, strlen(oldmono)); | 164 | bzero(wrapped, lenwrap); |
| 163 | bzero(wrapped, strlen(wrapped)); | ||
| 164 | free(newmono); | 165 | free(newmono); |
| 165 | free(oldmono); | ||
| 166 | free(wrapped); | 166 | free(wrapped); |
| 167 | 167 | ||
| 168 | return msg; | 168 | return msg; |
| 169 | } | 169 | } |
| 170 | 170 | ||
| 171 | static char *obscure_msg(const char *old, const char *newval, const struct passwd *pwdp) | 171 | static const char * |
| 172 | obscure_msg(const char *old, const char *newval, const struct passwd *pwdp) | ||
| 172 | { | 173 | { |
| 173 | int maxlen, oldlen, newlen; | 174 | int maxlen, oldlen, newlen; |
| 174 | char *new1, *old1, *msg; | 175 | char *new1, *old1; |
| 176 | const char *msg; | ||
| 175 | 177 | ||
| 176 | oldlen = strlen(old); | 178 | oldlen = strlen(old); |
| 177 | newlen = strlen(newval); | 179 | newlen = strlen(newval); |
| @@ -233,7 +235,7 @@ static char *obscure_msg(const char *old, const char *newval, const struct passw | |||
| 233 | 235 | ||
| 234 | extern int obscure(const char *old, const char *newval, const struct passwd *pwdp) | 236 | extern int obscure(const char *old, const char *newval, const struct passwd *pwdp) |
| 235 | { | 237 | { |
| 236 | char *msg = obscure_msg(old, newval, pwdp); | 238 | const char *msg = obscure_msg(old, newval, pwdp); |
| 237 | 239 | ||
| 238 | /* if (msg) { */ | 240 | /* if (msg) { */ |
| 239 | if (msg != NULL) { | 241 | if (msg != NULL) { |
