]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core: use memdup_suffix0() at one more place
authorYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 7 Oct 2024 10:34:08 +0000 (19:34 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 8 Oct 2024 05:43:23 +0000 (14:43 +0900)
src/core/dbus-execute.c

index 51882698b6d7afb16118ce8fc6f0f0888e659f61..abb5f1f81ea91f63e4441efa5e58558a625080b6 100644 (file)
@@ -2411,13 +2411,10 @@ int bus_exec_context_set_transient_property(
                                 c->log_extra_fields = t;
                         }
 
-                        copy = malloc(sz + 1);
+                        copy = memdup_suffix0(p, sz);
                         if (!copy)
                                 return -ENOMEM;
 
-                        memcpy(copy, p, sz);
-                        ((uint8_t*) copy)[sz] = 0;
-
                         if (!utf8_is_valid(copy))
                                 return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS, "Journal field is not valid UTF-8");