From 7e39a481cfb10af6bd50fbb3e6afb09fa437eeec Mon Sep 17 00:00:00 2001 From: tytso Date: Mon, 16 Jan 2006 04:13:12 +0000 Subject: [PATCH] Fix bug which would cause pwgen to loop forever if the password length specified is 1. --- ChangeLog | 5 +++++ debian/changelog | 4 +++- pwgen.c | 4 ++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 55f6d7b..8c8819d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2006-01-15 Theodore Ts'o + + * pwgen.c (main): Fix bug which would cause pwgen to loop forever + if the password length specified is 1. + 2005-06-15 Theodore Ts'o * pw_phonemes.c (pw_phonemes): Allow one or more capital letters diff --git a/debian/changelog b/debian/changelog index 2ab8a77..8162fa6 100644 --- a/debian/changelog +++ b/debian/changelog @@ -2,8 +2,10 @@ pwgen (2.04-2) unstable; urgency=low * Add a udeb for debian-installer. Thanks to Martin Michlmayr for the patch. (Closes: #271115) + * Fix bug which would cause pwgen to loop forever if the password length + is 1. - -- Theodore Y. Ts'o Sun, 15 Jan 2006 22:31:01 -0500 + -- Theodore Y. Ts'o Sun, 15 Jan 2006 23:11:10 -0500 pwgen (2.04-1) unstable; urgency=low diff --git a/pwgen.c b/pwgen.c index 3af933b..a371f92 100644 --- a/pwgen.c +++ b/pwgen.c @@ -158,6 +158,10 @@ int main(int argc, char **argv) pw_length = strtol(argv[optind], &tmp, 0); if (pw_length < 5) pwgen = pw_rand; + if (pw_length <= 2) + pwgen_flags &= ~PW_UPPERS; + if (pw_length <= 1) + pwgen_flags &= ~PW_DIGITS; if (*tmp) { fprintf(stderr, "Invalid password length: %s\n", argv[optind]);