Re: [PATCH 2/3] libsepol: fix potential memory leak in common_copy_callback

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Dec 5, 2022 at 7:13 AM Jie Lu <lujie54@xxxxxxxxxx> wrote:
>
> In common_copy_callback(), destroy new_common->permissions when the function fails.
>
> Signed-off-by: Jie Lu <lujie54@xxxxxxxxxx>
> ---
>  libsepol/src/expand.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/libsepol/src/expand.c b/libsepol/src/expand.c
> index 8d19850e..b44cfd4f 100644
> --- a/libsepol/src/expand.c
> +++ b/libsepol/src/expand.c
> @@ -297,6 +297,7 @@ static int common_copy_callback(hashtab_key_t key, hashtab_datum_t datum,
>                            (hashtab_datum_t) new_common);
>         if (ret) {
>                 ERR(state->handle, "hashtab overflow");
> +               symtab_destroy(&new_common->permissions);
>                 free(new_common);
>                 free(new_id);
>                 return -1;

The call to hashtab_map() below this also needs similar cleanup if
there is an error. In fact, this whole function really needs common
cleanup code with a goto that code upon an error.

Thanks,
Jim


> --
> 2.27.0
>



[Index of Archives]     [Selinux Refpolicy]     [Linux SGX]     [Fedora Users]     [Fedora Desktop]     [Yosemite Photos]     [Yosemite Camping]     [Yosemite Campsites]     [KDE Users]     [Gnome Users]

  Powered by Linux