diff mbox series

[11/12] vpn: Fix extracting of PrefixLength D-Bus value

Message ID 20250124185916.1546471-12-jussi.laakkonen@jolla.com (mailing list archive)
State New
Headers show
Series Improve WireGuard disconnect, error and hostname lookup | expand

Commit Message

Jussi Laakkonen Jan. 24, 2025, 6:59 p.m. UTC
The PrefixLength value is stored as a DBUS_TYPE_BYTE, and is an unsigned
char, thus should be read as such. This fixes crash when trying to read
the value into a char*.
---
 plugins/vpn.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/plugins/vpn.c b/plugins/vpn.c
index 42396d2a..332d8e83 100644
--- a/plugins/vpn.c
+++ b/plugins/vpn.c
@@ -412,8 +412,8 @@  static int extract_ip(DBusMessageIter *array, int family,
 			dbus_message_iter_get_basic(&value, &netmask);
 			DBG("netmask %s", netmask);
 		} else if (g_str_equal(key, "PrefixLength")) {
-			dbus_message_iter_get_basic(&value, &netmask);
-			DBG("prefix length %s", netmask);
+			dbus_message_iter_get_basic(&value, &prefix_len);
+			DBG("prefix length %u", prefix_len);
 		} else if (g_str_equal(key, "Peer")) {
 			dbus_message_iter_get_basic(&value, &peer);
 			DBG("peer %s", peer);
@@ -436,7 +436,6 @@  static int extract_ip(DBusMessageIter *array, int family,
 								gateway);
 		break;
 	case AF_INET6:
-		prefix_len = atoi(netmask);
 		connman_ipaddress_set_ipv6(data->ip, address, prefix_len,
 								gateway);
 		break;