From 9f0d2d64cc3d4c5f202aeaa69d1cea70ad86a52c Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Mon, 7 Oct 2024 19:34:08 +0900 Subject: [PATCH] core: use memdup_suffix0() at one more place --- src/core/dbus-execute.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/core/dbus-execute.c b/src/core/dbus-execute.c index 51882698b6d..abb5f1f81ea 100644 --- a/src/core/dbus-execute.c +++ b/src/core/dbus-execute.c @@ -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"); -- 2.47.3