From: Adrian Vovk Date: Thu, 1 Feb 2024 16:16:44 +0000 (-0500) Subject: homed: Add some missing asserts X-Git-Tag: v256-rc1~878 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e2a40cc7b94755f1b2a9b0fe82e823ea48e46178;p=thirdparty%2Fsystemd.git homed: Add some missing asserts These functions expect secrets to be passed in (some even dereference the variables), but fail to assert that they're non-null. So this commit adds some assertions --- diff --git a/src/home/homed-home.c b/src/home/homed-home.c index fc9dfcff245..8b0df9175ef 100644 --- a/src/home/homed-home.c +++ b/src/home/homed-home.c @@ -1323,6 +1323,7 @@ static int home_fixate_internal( int r; assert(h); + assert(secret); assert(IN_SET(for_state, HOME_FIXATING, HOME_FIXATING_FOR_ACTIVATION, HOME_FIXATING_FOR_ACQUIRE)); r = home_start_work(h, "inspect", h->record, secret); @@ -1343,6 +1344,7 @@ int home_fixate(Home *h, UserRecord *secret, sd_bus_error *error) { int r; assert(h); + assert(secret); switch (home_get_state(h)) { case HOME_ABSENT: @@ -1370,6 +1372,7 @@ static int home_activate_internal(Home *h, UserRecord *secret, HomeState for_sta int r; assert(h); + assert(secret); assert(IN_SET(for_state, HOME_ACTIVATING, HOME_ACTIVATING_FOR_ACQUIRE)); r = home_start_work(h, "activate", h->record, secret); @@ -1384,6 +1387,7 @@ int home_activate(Home *h, UserRecord *secret, sd_bus_error *error) { int r; assert(h); + assert(secret); switch (home_get_state(h)) { case HOME_UNFIXATED: @@ -1417,6 +1421,7 @@ static int home_authenticate_internal(Home *h, UserRecord *secret, HomeState for int r; assert(h); + assert(secret); assert(IN_SET(for_state, HOME_AUTHENTICATING, HOME_AUTHENTICATING_WHILE_ACTIVE, HOME_AUTHENTICATING_FOR_ACQUIRE)); r = home_start_work(h, "inspect", h->record, secret); @@ -1432,6 +1437,7 @@ int home_authenticate(Home *h, UserRecord *secret, sd_bus_error *error) { int r; assert(h); + assert(secret); state = home_get_state(h); switch (state) { @@ -1504,6 +1510,7 @@ int home_create(Home *h, UserRecord *secret, sd_bus_error *error) { int r; assert(h); + assert(secret); switch (home_get_state(h)) { case HOME_INACTIVE: { @@ -1840,6 +1847,8 @@ int home_passwd(Home *h, int r; assert(h); + assert(new_secret); + assert(old_secret); if (h->signed_locally <= 0) /* Don't allow changing of records not signed only by us */ return sd_bus_error_setf(error, BUS_ERROR_HOME_RECORD_SIGNED, "Home %s is signed and cannot be modified locally.", h->user_name); @@ -1986,6 +1995,7 @@ static int home_unlock_internal(Home *h, UserRecord *secret, HomeState for_state int r; assert(h); + assert(secret); assert(IN_SET(for_state, HOME_UNLOCKING, HOME_UNLOCKING_FOR_ACQUIRE)); r = home_start_work(h, "unlock", h->record, secret); @@ -1998,7 +2008,9 @@ static int home_unlock_internal(Home *h, UserRecord *secret, HomeState for_state int home_unlock(Home *h, UserRecord *secret, sd_bus_error *error) { int r; + assert(h); + assert(secret); r = home_ratelimit(h, error); if (r < 0) diff --git a/src/home/user-record-util.c b/src/home/user-record-util.c index 6c427138669..8620371ac6a 100644 --- a/src/home/user-record-util.c +++ b/src/home/user-record-util.c @@ -1155,6 +1155,7 @@ int user_record_merge_secret(UserRecord *h, UserRecord *secret) { int r; assert(h); + assert(secret); /* Merges the secrets from 'secret' into 'h'. */