mirror of
https://git.proxmox.com/git/pve-common
synced 2025-04-28 12:10:17 +00:00
encrypt_pw: check return value matches expected format
since this manually constructs the input string for `crypt`, which looks different depending on used prefix/hashing algorithm, ensure that it was understood by crypt and that it returned a proper hashed password line. Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
This commit is contained in:
parent
6cbbb1863d
commit
d9e544ff71
@ -1824,7 +1824,12 @@ sub encrypt_pw {
|
||||
die "Cannot hash password, unknown crypt prefix '$prefix'\n";
|
||||
}
|
||||
|
||||
return crypt(encode("utf8", $pw), $input);
|
||||
my $res = crypt(encode("utf8", $pw), $input);
|
||||
if ($res =~ m/^\$$prefix\$/) {
|
||||
return $res;
|
||||
} else {
|
||||
die "Failed to hash password!\n";
|
||||
}
|
||||
}
|
||||
|
||||
# intended usage: convert_size($val, "kb" => "gb")
|
||||
|
Loading…
Reference in New Issue
Block a user