From: Alejandro Colomar Date: Wed, 7 Jan 2026 22:39:53 +0000 (+0100) Subject: lib/chkhash.c: is_valid_hash(): Accept a leading '!' X-Git-Tag: 4.19.1~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1a280cd26426bda9f05e8a4cb48f570788f1e719;p=thirdparty%2Fshadow.git lib/chkhash.c: is_valid_hash(): Accept a leading '!' A leading '!' means that the account is locked. Fixes: c44f1e096a19 (2025-07-20; "chpasswd: Check hash before write when using -e") Link: Link: Reported-by: Chris Hofstaedtler Reviewed-by: Chris Hofstaedtler Cc: vinz Signed-off-by: Alejandro Colomar Cherry-picked-from: 87ec7a52ab25 (2026-01-07; "lib/chkhash.c: is_valid_hash(): Accept a leading '!'") Signed-off-by: Alejandro Colomar --- diff --git a/lib/chkhash.c b/lib/chkhash.c index 668705007..cb45f3aa9 100644 --- a/lib/chkhash.c +++ b/lib/chkhash.c @@ -7,6 +7,8 @@ #include #include +#include "string/strcmp/strprefix.h" + /* * match_regex - return true if match, false if not @@ -37,6 +39,8 @@ match_regex(const char *pattern, const char *string) bool is_valid_hash(const char *hash) { + hash = strprefix(hash, "!") ?: hash; + // Minimum hash length if (strlen(hash) < 13) return false;