diff --git a/ChangeLog b/ChangeLog index 58d7ef10..cad11f96 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2008-05-26 Nicolas François + + * libmisc/valid.c: Avoid implicit conversion of pointers /chars to + booleans. + * libmisc/valid.c: Add brackets. + 2008-05-26 Nicolas François * libmisc/yesno.c: yes_or_no returns a bool instead of int. diff --git a/libmisc/valid.c b/libmisc/valid.c index 3b68b9ca..e95b475a 100644 --- a/libmisc/valid.c +++ b/libmisc/valid.c @@ -61,11 +61,12 @@ int valid (const char *password, const struct passwd *ent) * routine is meant to waste CPU time. */ - if (ent->pw_name && !ent->pw_passwd[0]) { - if (!password[0]) + if ((NULL != ent->pw_name) && ('\0' == ent->pw_passwd[0])) { + if ('\0' == password[0]) { return (1); /* user entered nothing */ - else + } else { return (0); /* user entered something! */ + } } /* @@ -93,9 +94,11 @@ int valid (const char *password, const struct passwd *ent) * cause non-existent users to not be validated. */ - if (ent->pw_name && strcmp (encrypted, ent->pw_passwd) == 0) + if ((NULL != ent->pw_name) && + (strcmp (encrypted, ent->pw_passwd) == 0)) { return (1); - else + } else { return (0); + } }