[Dnsmasq-discuss] [PATCH] Fix potential memory leak
Brian Haley
haleyb.dev at gmail.com
Sun Mar 17 17:09:36 UTC 2024
Hi,
On 3/17/24 9:38 AM, Geert Stappers wrote:
> From: Brian Haley <haleyb.dev at gmail.com>
>
> When a new IPv6 address is being added to a dhcp_config
> struct, if there is anything invalid regarding the prefix
> it looks like there is a potential memory leak.
> ret_err_free() should be used to free it.
>
> Signed-off-by: Brian Haley <haleyb.dev at gmail.com>
> ---
> src/option.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/option.c b/src/option.c
> index f4ff7c0..db758ce 100644
> --- a/src/option.c
> +++ b/src/option.c
> @@ -4034,7 +4034,7 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
> ((((u64)1<<(128-new_addr->prefixlen))-1) & addrpart) != 0)
> {
> dhcp_config_free(new);
> - ret_err(_("bad IPv6 prefix"));
> + ret_err_free(_("bad IPv6 prefix"), new_addr);
> }
>
> new_addr->flags |= ADDRLIST_PREFIX;
Nak.
I don't believe this stands on it's own - new_addr has been linked into
the list by this point, so freeing it could cause other issues like
invalid memory references. My original submission moved that operation
until later in the function to avoid this, so I would rather see that
version merged.
Thanks,
-Brian
More information about the Dnsmasq-discuss
mailing list