Hi,

first of all, thank you for fixing this bug. I was also bitten by it
and I am happy that it was fixed already by a patch.

I'd like to suggest some improvements, though. First, I think the new
variable introduced should be 'gint' rather than 'int' to stay
consistent. Also, there were some white space issues with one of the new
lines. I add an updated patch here to this message. It is also a tad
shorter because of the ternary operator. Its usage is often a matter of
taste but I think it fits nicely here.

Thanks and looking forward to comments,

   Wolfram
From: Patrizio Tufarolo <patriziotufar...@gmail.com>
Date: Wed, 25 May 2022 08:11:36 +0200
Subject: fix_segfault_on_DNS_entries

Slightly edited by Wolfram Sang <w...@kernel.org>
---
 src/modules/nm09.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/modules/nm09.c b/src/modules/nm09.c
index 2b3098b..02d0e20 100644
--- a/src/modules/nm09.c
+++ b/src/modules/nm09.c
@@ -529,7 +529,7 @@ static mmguiconn_t mmgui_module_connection_get_params(mmguicore_t mmguicore, con
 	GVariant *connconsec, *connipv4sec, *conntechsec;
 	GVariant *conndnsvar;
 	gchar *conntypestr, *connparamstr;
-	gint i, addrint;
+	gint i, addrint, n_dns_entries;
 	GVariant *addrvar;
 	gchar *techstr;
 	mmguiconn_t connection;
@@ -630,7 +630,8 @@ static mmguiconn_t mmgui_module_connection_get_params(mmguicore_t mmguicore, con
 					if (connipv4sec != NULL) {
 						/*DNS*/
 						conndnsvar = g_variant_lookup_value(connipv4sec, "dns", G_VARIANT_TYPE_ARRAY);
-						for (i = 0; i < g_variant_n_children(conndnsvar); i++) {
+						n_dns_entries = conndnsvar ? g_variant_n_children(conndnsvar) : 0;
+						for (i = 0; i < n_dns_entries; i++) {
 							addrvar = g_variant_get_child_value(conndnsvar, i);
 							addrint = ntohl(g_variant_get_uint32(addrvar));
 							if (connection->dns1 == NULL) {

Attachment: signature.asc
Description: PGP signature

Reply via email to