From e344df432bdca72e47374637e2c9ac28d469ac61 Mon Sep 17 00:00:00 2001 From: Andrew Zaborowski Date: Mon, 11 Mar 2019 15:43:20 +0100 Subject: [PATCH] wiphy: Fix printing supported iftypes dbus_iftype_to_string returns NULL for unknown iftypes, the strdup will also return NULL and ret[i] will be assigned a NULL. As a result the l_strjoinv will not print the known iftypes that might have come after that and will the l_strfreev will leak the strduped strings. --- src/wiphy.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/wiphy.c b/src/wiphy.c index 6a895e73..559c0605 100644 --- a/src/wiphy.c +++ b/src/wiphy.c @@ -310,10 +310,14 @@ static char **wiphy_get_supported_iftypes(struct wiphy *wiphy) unsigned int j; for (j = 0, i = 0; i < sizeof(wiphy->supported_iftypes) * 8; i++) { + const char *str; + if (!(wiphy->supported_iftypes & (1 << i))) continue; - ret[j++] = l_strdup(dbus_iftype_to_string(i + 1)); + str = dbus_iftype_to_string(i + 1); + if (str) + ret[j++] = l_strdup(str); } return ret;