- 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.
This commit is contained in:
parent
eedd1be730
commit
dd9dce104d
@ -1,6 +1,7 @@
|
|||||||
/* vi: set sw=4 ts=4: */
|
/* vi: set sw=4 ts=4: */
|
||||||
/*
|
/*
|
||||||
* Copyright 1989 - 1994, Julianne Frances Haugh <jockgrrl@austin.rr.com>
|
* Copyright 1989 - 1994, Julianne Frances Haugh <jockgrrl@austin.rr.com>
|
||||||
|
* Copyright 2006, Bernhard Fischer <busybox@busybox.net>
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@ -81,23 +82,23 @@ static int similiar(const char *old, const char *newval)
|
|||||||
|
|
||||||
static int simple(const char *newval)
|
static int simple(const char *newval)
|
||||||
{
|
{
|
||||||
int digits = 0;
|
#define digits 1
|
||||||
int uppers = 0;
|
#define uppers 2
|
||||||
int lowers = 0;
|
#define lowers 3
|
||||||
int others = 0;
|
#define others 4
|
||||||
int c;
|
int c, is_simple = 0;
|
||||||
int size;
|
int size;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; (c = *newval++) != 0; i++) {
|
for (i = 0; (c = *newval++) != 0; i++) {
|
||||||
if (isdigit(c))
|
if (isdigit(c))
|
||||||
digits = c;
|
is_simple |= digits;
|
||||||
else if (isupper(c))
|
else if (isupper(c))
|
||||||
uppers = c;
|
is_simple |= uppers;
|
||||||
else if (islower(c))
|
else if (islower(c))
|
||||||
lowers = c;
|
is_simple |= lowers;
|
||||||
else
|
else
|
||||||
others = c;
|
is_simple |= others;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -106,19 +107,23 @@ static int simple(const char *newval)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
size = 9;
|
size = 9;
|
||||||
if (digits)
|
if (is_simple & digits)
|
||||||
size--;
|
size--;
|
||||||
if (uppers)
|
if (is_simple & uppers)
|
||||||
size--;
|
size--;
|
||||||
if (lowers)
|
if (is_simple & lowers)
|
||||||
size--;
|
size--;
|
||||||
if (others)
|
if (is_simple & others)
|
||||||
size--;
|
size--;
|
||||||
|
|
||||||
if (size <= i)
|
if (size <= i)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
#undef digits
|
||||||
|
#undef uppers
|
||||||
|
#undef lowers
|
||||||
|
#undef others
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *str_lower(char *string)
|
static char *str_lower(char *string)
|
||||||
@ -163,8 +168,8 @@ password_check(const char *old, const char *newval, const struct passwd *pwdp)
|
|||||||
msg = "rotated";
|
msg = "rotated";
|
||||||
}
|
}
|
||||||
|
|
||||||
bzero(newmono, strlen(newmono));
|
memset(newmono, 0, strlen(newmono));
|
||||||
bzero(wrapped, lenwrap * 2);
|
memset(wrapped, 0, lenwrap * 2);
|
||||||
free(newmono);
|
free(newmono);
|
||||||
free(wrapped);
|
free(wrapped);
|
||||||
|
|
||||||
@ -220,8 +225,8 @@ obscure_msg(const char *old, const char *newval, const struct passwd *pwdp)
|
|||||||
|
|
||||||
msg = password_check(old1, new1, pwdp);
|
msg = password_check(old1, new1, pwdp);
|
||||||
|
|
||||||
bzero(new1, newlen);
|
memset(new1, 0, newlen);
|
||||||
bzero(old1, oldlen);
|
memset(old1, 0, oldlen);
|
||||||
free(new1);
|
free(new1);
|
||||||
free(old1);
|
free(old1);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user