The getdef_num implementation allows -1 to be specified in login.defs.
In general, -1 should be treated the same way as "not specified". In
this case, casting -1 to size_t leads to every password being "too
short."
Reviewed-by: Alejandro Colomar <alx@kernel.org>
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
/*@notnull@*/const char *new)
{
size_t maxlen, oldlen, newlen;
+ int minlen;
char *new1, *old1;
const char *msg;
const char *result;
oldlen = strlen (old);
newlen = strlen (new);
- if (newlen < (size_t) getdef_num ("PASS_MIN_LEN", 0)) {
+ minlen = getdef_num ("PASS_MIN_LEN", 0);
+ if (minlen != -1 && newlen < (size_t) minlen) {
return _("too short");
}