Skip to contentSkip to conversation

netconfig: fix freeing invalid pointer

PATCH Applied James Prestwood 2 participants 2 messages Nov 23, 2020 – Nov 24, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 netconfig: fix freeing invalid pointer

If l_rtnl_ifaddr4_extract does not set the values they would get freed. Instead initialize to NULL so the cleanup free is a no op.

---
 src/netconfig.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
src/netconfig.c +3 -3
index dcb88749..610635cd 100644
@@ -441,9 +441,9 @@ static void netconfig_ifaddr_added(struct netconfig *netconfig,
 					const struct ifaddrmsg *ifa,
 					uint32_t len)
 {
-	L_AUTO_FREE_VAR(char *, label);
-	L_AUTO_FREE_VAR(char *, ip);
-	L_AUTO_FREE_VAR(char *, broadcast);
+	L_AUTO_FREE_VAR(char *, label) = NULL;
+	L_AUTO_FREE_VAR(char *, ip) = NULL;
+	L_AUTO_FREE_VAR(char *, broadcast) = NULL;
 
 	l_rtnl_ifaddr4_extract(ifa, len, &label, &ip, &broadcast);
 	l_debug("%s: ifaddr %s/%u broadcast %s", label,
Signature · 1 line
2.26.2
#1 lore raw

Hi James,

Quoted 7 lines · James Prestwood

If l_rtnl_ifaddr4_extract does not set the values they would get freed. Instead initialize to NULL so the cleanup free is a no op.

---
  src/netconfig.c | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)

Applied, thanks.

Regards,
-Denis