From: Yu Watanabe Date: Tue, 18 Nov 2025 01:28:50 +0000 (+0900) Subject: libcrypt-util: add missing assertions X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d5267b22757a638e4f2c3b890e595f3a26041b6f;p=thirdparty%2Fsystemd.git libcrypt-util: add missing assertions --- diff --git a/src/shared/libcrypt-util.c b/src/shared/libcrypt-util.c index cff3f586cfd..26e907f866d 100644 --- a/src/shared/libcrypt-util.c +++ b/src/shared/libcrypt-util.c @@ -12,6 +12,7 @@ #include "strv.h" int make_salt(char **ret) { + assert(ret); #if HAVE_CRYPT_GENSALT_RA const char *e; @@ -86,6 +87,8 @@ int make_salt(char **ret) { /* Provide a poor man's fallback that uses a fixed size buffer. */ static char* systemd_crypt_ra(const char *phrase, const char *setting, void **data, int *size) { + assert(phrase); + assert(setting); assert(data); assert(size); @@ -125,6 +128,9 @@ int hash_password(const char *password, char **ret) { const char *p; int r, cd_size = 0; + assert(password); + assert(ret); + r = make_salt(&salt); if (r < 0) return log_debug_errno(r, "Failed to generate salt: %m"); @@ -143,6 +149,9 @@ int test_password_one(const char *hashed_password, const char *password) { int cd_size = 0; const char *k; + assert(hashed_password); + assert(password); + errno = 0; k = crypt_ra(password, hashed_password, &cd_data, &cd_size); if (!k) { @@ -158,6 +167,8 @@ int test_password_one(const char *hashed_password, const char *password) { int test_password_many(char **hashed_password, const char *password) { int r; + assert(password); + STRV_FOREACH(hpw, hashed_password) { r = test_password_one(*hpw, password); if (r < 0)