diff --git a/src/dbus.h b/src/dbus.h index 667b4d70..6416fa42 100644 --- a/src/dbus.h +++ b/src/dbus.h @@ -36,7 +36,8 @@ #define IWD_ADHOC_INTERFACE "net.connman.iwd.AdHoc" #define IWD_STATION_INTERFACE "net.connman.iwd.Station" -#define IWD_AGENT_MANAGER_PATH "/" +#define IWD_BASE_PATH "/net/connman/iwd" +#define IWD_AGENT_MANAGER_PATH IWD_BASE_PATH struct l_dbus; diff --git a/src/knownnetworks.c b/src/knownnetworks.c index 0fa55d56..e5cbc01b 100644 --- a/src/knownnetworks.c +++ b/src/knownnetworks.c @@ -77,7 +77,8 @@ static const char *known_network_get_path(const struct network_info *network) static char path[256]; unsigned int pos = 0, i; - path[pos++] = '/'; + L_WARN_ON((pos = snprintf(path, sizeof(path), "%s/", + IWD_BASE_PATH)) >= (int) sizeof(path)); for (i = 0; network->ssid[i] && pos < sizeof(path); i++) pos += snprintf(path + pos, sizeof(path) - pos, "%02x", @@ -85,6 +86,7 @@ static const char *known_network_get_path(const struct network_info *network) snprintf(path + pos, sizeof(path) - pos, "_%s", security_to_str(network->type)); + path[sizeof(path) - 1] = '\0'; return path; } diff --git a/src/netdev.c b/src/netdev.c index 47774445..9e7f3eda 100644 --- a/src/netdev.c +++ b/src/netdev.c @@ -310,10 +310,13 @@ struct device *netdev_get_device(struct netdev *netdev) const char *netdev_get_path(struct netdev *netdev) { - static char path[26]; + static char path[256]; + + L_WARN_ON(snprintf(path, sizeof(path), "%s/%u", + wiphy_get_path(netdev->wiphy), + netdev->index) >= (int) sizeof(path)); + path[sizeof(path) - 1] = '\0'; - snprintf(path, sizeof(path), "%s/%u", wiphy_get_path(netdev->wiphy), - netdev->index); return path; } diff --git a/src/wiphy.c b/src/wiphy.c index 3ec9ef4f..36e6c73d 100644 --- a/src/wiphy.c +++ b/src/wiphy.c @@ -267,9 +267,12 @@ check_blacklist: const char *wiphy_get_path(struct wiphy *wiphy) { - static char path[15]; + static char path[256]; + + L_WARN_ON(snprintf(path, sizeof(path), "%s/%d", IWD_BASE_PATH, + wiphy->id) >= (int) sizeof(path)); + path[sizeof(path) - 1] = '\0'; - snprintf(path, sizeof(path), "/%d", wiphy->id); return path; }