diff mbox series

rpcbind: fix double free in init_transport

Message ID 20220129004417.GA10610@altlinux.org (mailing list archive)
State New, archived
Headers show
Series rpcbind: fix double free in init_transport | expand

Commit Message

Dmitry V. Levin Jan. 29, 2022, 12:44 a.m. UTC
$ 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/
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
---
 src/rpcbind.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Steve Dickson Feb. 1, 2022, 1:48 p.m. UTC | #1
On 1/28/22 19:44, Dmitry V. Levin wrote:
> $ 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/
> Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
Committed... (tag: rpcbind-1_2_7-rc1)

steved.
> ---
>   src/rpcbind.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/src/rpcbind.c b/src/rpcbind.c
> index 25d8a90..ecebe97 100644
> --- a/src/rpcbind.c
> +++ b/src/rpcbind.c
> @@ -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++;
diff mbox series

Patch

diff --git a/src/rpcbind.c b/src/rpcbind.c
index 25d8a90..ecebe97 100644
--- a/src/rpcbind.c
+++ b/src/rpcbind.c
@@ -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++;