svn commit: trunk/busybox/libbb
Ihno Krumreich
ihno at suse.de
Fri Jan 13 11:29:12 UTC 2006
hi,
The definition of the constants digits, upper, lower and others
does not seams to be right.
If lowers is definied, the code will think that digits is set.
The right definition would be:
#define digits 1
#define uppers 2
#define lowers 4
#define others 8
Ihno
On Thu, Jan 12, 2006 at 07:38:14AM -0800, aldot at busybox.net wrote:
> Author: aldot
> Date: 2006-01-12 07:38:12 -0800 (Thu, 12 Jan 2006)
> New Revision: 13259
>
> Log:
> - 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.
>
>
> Modified:
> trunk/busybox/libbb/obscure.c
>
>
> Changeset:
> Modified: trunk/busybox/libbb/obscure.c
> ===================================================================
> --- trunk/busybox/libbb/obscure.c 2006-01-12 13:15:49 UTC (rev 13258)
> +++ trunk/busybox/libbb/obscure.c 2006-01-12 15:38:12 UTC (rev 13259)
> @@ -1,6 +1,7 @@
> /* vi: set sw=4 ts=4: */
> /*
> * Copyright 1989 - 1994, Julianne Frances Haugh <jockgrrl at austin.rr.com>
> + * Copyright 2006, Bernhard Fischer <busybox at busybox.net>
> * All rights reserved.
> *
> * Redistribution and use in source and binary forms, with or without
> @@ -81,23 +82,23 @@
>
> static int simple(const char *newval)
> {
> - int digits = 0;
> - int uppers = 0;
> - int lowers = 0;
> - int others = 0;
> - int c;
> +#define digits 1
> +#define uppers 2
> +#define lowers 3
> +#define others 4
> + int c, is_simple = 0;
> int size;
> int i;
>
> for (i = 0; (c = *newval++) != 0; i++) {
> if (isdigit(c))
> - digits = c;
> + is_simple |= digits;
> else if (isupper(c))
> - uppers = c;
> + is_simple |= uppers;
> else if (islower(c))
> - lowers = c;
> + is_simple |= lowers;
> else
> - others = c;
> + is_simple |= others;
> }
>
> /*
> @@ -106,19 +107,23 @@
> */
>
> size = 9;
> - if (digits)
> + if (is_simple & digits)
> size--;
> - if (uppers)
> + if (is_simple & uppers)
> size--;
> - if (lowers)
> + if (is_simple & lowers)
> size--;
> - if (others)
> + if (is_simple & others)
> size--;
>
> if (size <= i)
> return 0;
>
> return 1;
> +#undef digits
> +#undef uppers
> +#undef lowers
> +#undef others
> }
>
> static char *str_lower(char *string)
> @@ -163,8 +168,8 @@
> msg = "rotated";
> }
>
> - bzero(newmono, strlen(newmono));
> - bzero(wrapped, lenwrap * 2);
> + memset(newmono, 0, strlen(newmono));
> + memset(wrapped, 0, lenwrap * 2);
> free(newmono);
> free(wrapped);
>
> @@ -220,8 +225,8 @@
>
> msg = password_check(old1, new1, pwdp);
>
> - bzero(new1, newlen);
> - bzero(old1, oldlen);
> + memset(new1, 0, newlen);
> + memset(old1, 0, oldlen);
> free(new1);
> free(old1);
>
>
> _______________________________________________
> busybox-cvs mailing list
> busybox-cvs at busybox.net
> http://busybox.net/cgi-bin/mailman/listinfo/busybox-cvs
--
Best regards/Mit freundlichen Grüßen
Ihno Krumreich
"Never trust a computer you can lift."
--
Ihno Krumreich ihno at suse.de
SUSE LINUX Products GmbH Projectmanager S390 & zSeries
Maxfeldstr. 5 +49-911-74053-439
D-90409 Nürnberg http://www.suse.de
More information about the busybox-cvs
mailing list