From: James Prestwood <prestwoj@gmail.com>
To: iwd@lists.linux.dev
Cc: James Prestwood <prestwoj@gmail.com>
Subject: [PATCH] station: fix setting an empty affinities list
Date: Thu, 17 Apr 2025 09:16:01 -0700 [thread overview]
Message-ID: <20250417161601.249876-1-prestwoj@gmail.com> (raw)
A prior patch broke this by checking the return of
l_dbus_message_iter_next_entry. This was really subtle but the logic
actually relied on _not_ checking that return in order to handle
empty lists.
Instead of reverting the logic was adapted/commented to make it more
clear what the API expects from DBus. If list contains at least one
value the first element path will get set, if it contains zero
values "new_path" will be set to NULL which will then cause the
list to be cleared later on.
This both fixes the regression, and makes it clear that a zero
element list is supported and handled.
---
src/station.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/src/station.c b/src/station.c
index 14c93671..d8016c2a 100644
--- a/src/station.c
+++ b/src/station.c
@@ -4815,7 +4815,7 @@ static struct l_dbus_message *station_property_set_affinities(
struct l_dbus_message_iter array;
const char *sender = l_dbus_message_get_sender(message);
char *old_path = l_queue_peek_head(station->affinities);
- const char *new_path = NULL;
+ const char *new_path;
struct scan_bss *new_bss = NULL;
struct scan_bss *old_bss = NULL;
bool lower_threshold = false;
@@ -4835,11 +4835,15 @@ static struct l_dbus_message *station_property_set_affinities(
if (!l_dbus_message_iter_get_variant(new_value, "ao", &array))
return dbus_error_invalid_args(message);
- /* Get first entry, there should be only one */
+ /* Get first entry, or if an empty array set the path to NULL */
if (!l_dbus_message_iter_next_entry(&array, &new_path))
- return dbus_error_invalid_args(message);
+ new_path = NULL;
- if (l_dbus_message_iter_next_entry(&array, &new_path))
+ /*
+ * Only allowing single values for now. If there is more than a single
+ * value, fail
+ */
+ if (new_path && l_dbus_message_iter_next_entry(&array, &new_path))
return dbus_error_invalid_args(message);
old_path = l_queue_peek_head(station->affinities);
--
2.34.1
next reply other threads:[~2025-04-17 16:16 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-17 16:16 James Prestwood [this message]
2025-04-23 14:43 ` [PATCH] station: fix setting an empty affinities list Denis Kenzior
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250417161601.249876-1-prestwoj@gmail.com \
--to=prestwoj@gmail.com \
--cc=iwd@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox