]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
libcrypt-util: add missing assertions
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 18 Nov 2025 01:28:50 +0000 (10:28 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 2 Jan 2026 03:54:01 +0000 (12:54 +0900)
src/shared/libcrypt-util.c

index cff3f586cfd283ff3fd7acc13c7e3db5dbcb0e54..26e907f866d9684c2885689c736d15b92d538f01 100644 (file)
@@ -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)