Fix unix_crypt not to fail false positively

This commit is contained in:
Ilia
2022-06-16 00:45:16 +03:00
parent e20ebc2da9
commit 4aa2154d42

View File

@@ -11001,16 +11001,15 @@ string.
sub unix_crypt
{
my ($pass, $salt) = @_;
return "" if ($salt !~ /^[\$a-zA-Z0-9\.\/]{2}/); # same as real crypt
my $rv = eval "crypt(\$pass, \$salt)";
my $err = $@;
return $rv if ($rv && !$@);
return "" if ($salt !~ /^[\$a-zA-Z0-9]{2}/); # same as real crypt
my $rv = eval { crypt($pass, $salt) };
return $rv if (!$@);
eval "use Crypt::UnixCrypt";
if (!$@) {
return Crypt::UnixCrypt::crypt($pass, $salt);
}
else {
&error("Failed to encrypt password : $err");
&error("Failed to encrypt password : $@");
}
}