core/dbus-execute: normalize "rename" arg properly
authorMike Yuan <me@yhndnzj.com>
Sat, 3 Aug 2024 11:18:01 +0000 (13:18 +0200)
committerMike Yuan <me@yhndnzj.com>
Sun, 4 Aug 2024 04:51:25 +0000 (06:51 +0200)
Follow-up for 40dd2a1c24b886d9e635fef8f7b5336700df03c3

Addresses https://github.com/systemd/systemd/pull/33916#discussion_r1702616229

src/core/dbus-execute.c

index c7c43ce7d38f0e19eeefacfa3753e7b6b0f75215..264e2f0af6403c453536d9c7f7e4eac266450651 100644 (file)
@@ -2225,7 +2225,9 @@ int bus_exec_context_set_transient_property(
                         if (!credential_glob_valid(glob))
                                 return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Credential name or glob is invalid: %s", glob);
 
-                        if (!isempty(rename) && !credential_name_valid(rename))
+                        rename = empty_to_null(rename);
+
+                        if (rename && !credential_name_valid(rename))
                                 return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Credential name is invalid: %s", rename);
 
                         empty = false;