diff options
| author | Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> | 2006-01-12 15:38:12 +0000 |
|---|---|---|
| committer | Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> | 2006-01-12 15:38:12 +0000 |
| commit | dd9dce104d3c63a45554fd94d55df4c89455d95e (patch) | |
| tree | 7aac703ea3b6f25c9f409a335db764dbf1def399 /libbb | |
| parent | eedd1be730c40054ffb8a4665b596fbb6dab7150 (diff) | |
| download | busybox-w32-dd9dce104d3c63a45554fd94d55df4c89455d95e.tar.gz busybox-w32-dd9dce104d3c63a45554fd94d55df4c89455d95e.tar.bz2 busybox-w32-dd9dce104d3c63a45554fd94d55df4c89455d95e.zip | |
- shrink simple obscure stuff a tiny bit:
text data bss dec hex filename
789 0 0 789 315 obscure.o.oorig
771 0 0 771 303 obscure.o
- replace bzero by memset while at it.
Diffstat (limited to 'libbb')
| -rw-r--r-- | libbb/obscure.c | 39 |
1 files changed, 22 insertions, 17 deletions
diff --git a/libbb/obscure.c b/libbb/obscure.c index aa15e4097..259f6788d 100644 --- a/libbb/obscure.c +++ b/libbb/obscure.c | |||
| @@ -1,6 +1,7 @@ | |||
| 1 | /* vi: set sw=4 ts=4: */ | 1 | /* vi: set sw=4 ts=4: */ |
| 2 | /* | 2 | /* |
| 3 | * Copyright 1989 - 1994, Julianne Frances Haugh <jockgrrl@austin.rr.com> | 3 | * Copyright 1989 - 1994, Julianne Frances Haugh <jockgrrl@austin.rr.com> |
| 4 | * Copyright 2006, Bernhard Fischer <busybox@busybox.net> | ||
| 4 | * All rights reserved. | 5 | * All rights reserved. |
| 5 | * | 6 | * |
| 6 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without |
| @@ -81,23 +82,23 @@ static int similiar(const char *old, const char *newval) | |||
| 81 | 82 | ||
| 82 | static int simple(const char *newval) | 83 | static int simple(const char *newval) |
| 83 | { | 84 | { |
| 84 | int digits = 0; | 85 | #define digits 1 |
| 85 | int uppers = 0; | 86 | #define uppers 2 |
| 86 | int lowers = 0; | 87 | #define lowers 3 |
| 87 | int others = 0; | 88 | #define others 4 |
| 88 | int c; | 89 | int c, is_simple = 0; |
| 89 | int size; | 90 | int size; |
| 90 | int i; | 91 | int i; |
| 91 | 92 | ||
| 92 | for (i = 0; (c = *newval++) != 0; i++) { | 93 | for (i = 0; (c = *newval++) != 0; i++) { |
| 93 | if (isdigit(c)) | 94 | if (isdigit(c)) |
| 94 | digits = c; | 95 | is_simple |= digits; |
| 95 | else if (isupper(c)) | 96 | else if (isupper(c)) |
| 96 | uppers = c; | 97 | is_simple |= uppers; |
| 97 | else if (islower(c)) | 98 | else if (islower(c)) |
| 98 | lowers = c; | 99 | is_simple |= lowers; |
| 99 | else | 100 | else |
| 100 | others = c; | 101 | is_simple |= others; |
| 101 | } | 102 | } |
| 102 | 103 | ||
| 103 | /* | 104 | /* |
| @@ -106,19 +107,23 @@ static int simple(const char *newval) | |||
| 106 | */ | 107 | */ |
| 107 | 108 | ||
| 108 | size = 9; | 109 | size = 9; |
| 109 | if (digits) | 110 | if (is_simple & digits) |
| 110 | size--; | 111 | size--; |
| 111 | if (uppers) | 112 | if (is_simple & uppers) |
| 112 | size--; | 113 | size--; |
| 113 | if (lowers) | 114 | if (is_simple & lowers) |
| 114 | size--; | 115 | size--; |
| 115 | if (others) | 116 | if (is_simple & others) |
| 116 | size--; | 117 | size--; |
| 117 | 118 | ||
| 118 | if (size <= i) | 119 | if (size <= i) |
| 119 | return 0; | 120 | return 0; |
| 120 | 121 | ||
| 121 | return 1; | 122 | return 1; |
| 123 | #undef digits | ||
| 124 | #undef uppers | ||
| 125 | #undef lowers | ||
| 126 | #undef others | ||
| 122 | } | 127 | } |
| 123 | 128 | ||
| 124 | static char *str_lower(char *string) | 129 | static char *str_lower(char *string) |
| @@ -163,8 +168,8 @@ password_check(const char *old, const char *newval, const struct passwd *pwdp) | |||
| 163 | msg = "rotated"; | 168 | msg = "rotated"; |
| 164 | } | 169 | } |
| 165 | 170 | ||
| 166 | bzero(newmono, strlen(newmono)); | 171 | memset(newmono, 0, strlen(newmono)); |
| 167 | bzero(wrapped, lenwrap * 2); | 172 | memset(wrapped, 0, lenwrap * 2); |
| 168 | free(newmono); | 173 | free(newmono); |
| 169 | free(wrapped); | 174 | free(wrapped); |
| 170 | 175 | ||
| @@ -220,8 +225,8 @@ obscure_msg(const char *old, const char *newval, const struct passwd *pwdp) | |||
| 220 | 225 | ||
| 221 | msg = password_check(old1, new1, pwdp); | 226 | msg = password_check(old1, new1, pwdp); |
| 222 | 227 | ||
| 223 | bzero(new1, newlen); | 228 | memset(new1, 0, newlen); |
| 224 | bzero(old1, oldlen); | 229 | memset(old1, 0, oldlen); |
| 225 | free(new1); | 230 | free(new1); |
| 226 | free(old1); | 231 | free(old1); |
| 227 | 232 | ||
