Resolves: RHEL-155454, RHEL-155805, RHEL-155396, RHEL-158303, RHEL-158354, RHEL-143728, RHEL-168098, RHEL-143028
50 lines
1.7 KiB
Diff
50 lines
1.7 KiB
Diff
From 3f7834fccb42fa5ffffc17c93e43a1bbced00964 Mon Sep 17 00:00:00 2001
|
|
From: Mike Yuan <me@yhndnzj.com>
|
|
Date: Tue, 11 Feb 2025 18:13:01 +0100
|
|
Subject: [PATCH] bus-unit-util: add missing assertions
|
|
|
|
(cherry picked from commit 85f759baeeab59f25080bd19b2f338ae2d05ad8b)
|
|
|
|
Related: RHEL-143028
|
|
---
|
|
src/shared/bus-unit-util.c | 10 ++++++----
|
|
1 file changed, 6 insertions(+), 4 deletions(-)
|
|
|
|
diff --git a/src/shared/bus-unit-util.c b/src/shared/bus-unit-util.c
|
|
index 8667d10077..9128c06555 100644
|
|
--- a/src/shared/bus-unit-util.c
|
|
+++ b/src/shared/bus-unit-util.c
|
|
@@ -148,9 +148,11 @@ static int bus_append_string(sd_bus_message *m, const char *field, const char *e
|
|
}
|
|
|
|
static int bus_append_strv(sd_bus_message *m, const char *field, const char *eq, const char *separator, ExtractFlags flags) {
|
|
- const char *p;
|
|
int r;
|
|
|
|
+ assert(m);
|
|
+ assert(field);
|
|
+
|
|
r = sd_bus_message_open_container(m, 'r', "sv");
|
|
if (r < 0)
|
|
return bus_log_create_error(r);
|
|
@@ -167,16 +169,16 @@ static int bus_append_strv(sd_bus_message *m, const char *field, const char *eq,
|
|
if (r < 0)
|
|
return bus_log_create_error(r);
|
|
|
|
- for (p = eq;;) {
|
|
+ for (const char *p = eq;;) {
|
|
_cleanup_free_ char *word = NULL;
|
|
|
|
r = extract_first_word(&p, &word, separator, flags);
|
|
- if (r == 0)
|
|
- break;
|
|
if (r == -ENOMEM)
|
|
return log_oom();
|
|
if (r < 0)
|
|
return log_error_errno(r, "Invalid syntax: %s", eq);
|
|
+ if (r == 0)
|
|
+ break;
|
|
|
|
r = sd_bus_message_append_basic(m, 's', word);
|
|
if (r < 0)
|