eiwd

no dbus iwd with iwctl functionality
git clone https://git.daat.foo/repos/eiwd.git
Log | Files | Refs | Submodules | README | LICENSE

commit 0b8de3d5df66699cd70f87aae52912a02d92bbcc
parent 39bb4d07ee51d3b8b2c40710b42b8042c9c19524
Author: Denis Kenzior <denkenz@gmail.com>
Date:   Thu, 17 Oct 2019 11:49:11 -0500

monitor: Fix p2p channel list dumper

This dumper probably intended to update pos after invoking strncpy.
However, strncpy returns the number of bytes that *would* have been
copied and so the logic gets a bit complex to get completely right.

Instead, switch to using l_string since this is inside the monitor and
not particularly performance critical.

Diffstat:
Mmonitor/nlmon.c | 18+++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/monitor/nlmon.c b/monitor/nlmon.c @@ -3013,8 +3013,9 @@ static void print_p2p_channel_list(unsigned int level, const char *label, while (size) { uint8_t channels; - char str[128]; - int pos = 0; + struct l_string *string; + char *str; + bool first = true; if (size < 2 || size < 2 + bytes[1]) { printf("malformed P2P %s\n", label); @@ -3025,11 +3026,18 @@ static void print_p2p_channel_list(unsigned int level, const char *label, channels = *bytes++; size -= 2 + channels; - while (channels--) - snprintf(str + pos, sizeof(str) - pos, "%s%u", - pos ? ", " : "", (int) *bytes++); + string = l_string_new(128); + while (channels--) { + l_string_append_printf(string, "%s%u", + first ? "" : ", ", + (int ) *bytes++); + first = false; + } + + str = l_string_unwrap(string); print_attr(level + 2, "%s", str); + l_free(str); } }