Skip to contentSkip to conversation

rpcbind: fix double free in init_transport

PATCH In review Dmitry V. Levin 2 participants 2 messages Jan 29, 2022 – Feb 1, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rpcbind: fix double free in init_transport

$ rpcbind -h 127.0.0.1
free(): double free detected in tcache 2
Aborted
Fixes a6889bba949b ("Removed resource leaks from src/rpcbind.c")

Resolves: https://sourceforge.net/p/rpcbind/bugs/6/

---
 src/rpcbind.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
src/rpcbind.c +3 -1
index 25d8a90..ecebe97 100644
@@ -552,8 +552,10 @@ init_transport(struct netconfig *nconf)
 				syslog(LOG_ERR, "cannot bind %s on %s: %m",
 					(hosts[nhostsbak] == NULL) ? "*" :
 					hosts[nhostsbak], nconf->nc_netid);
-				if (res != NULL)
+				if (res != NULL) {
 					freeaddrinfo(res);
+					res = NULL;
+				}
 				continue;
 			} else
 				checkbind++;
Signature · 1 line
ldv
#1 lore raw
Quoted 7 lines · Dmitry V. Levin
$ rpcbind -h 127.0.0.1
free(): double free detected in tcache 2
Aborted
Fixes a6889bba949b ("Removed resource leaks from src/rpcbind.c")

Resolves: https://sourceforge.net/p/rpcbind/bugs/6/

Committed... (tag: rpcbind-1_2_7-rc1)

steved.

Quoted 20 lines
---
  src/rpcbind.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
src/rpcbind.c +3 -1
index 25d8a90..ecebe97 100644
@@ -552,8 +552,10 @@ init_transport(struct netconfig *nconf)
  				syslog(LOG_ERR, "cannot bind %s on %s: %m",
  					(hosts[nhostsbak] == NULL) ? "*" :
  					hosts[nhostsbak], nconf->nc_netid);
-				if (res != NULL)
+				if (res != NULL) {
  					freeaddrinfo(res);
+					res = NULL;
+				}
  				continue;
  			} else
  				checkbind++;