Re: [PATCH] restorecond: add check for strdup in strings_list_add

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

 



On Mon, Jul 10, 2023 at 9:49 PM Huaxin Lu <luhuaxin1@xxxxxxxxxx> wrote:
>
> Check the return value of strdup() to avoid null pointer reference.
>
> Signed-off-by: Huaxin Lu <luhuaxin1@xxxxxxxxxx>

Acked-by: James Carter <jwcart2@xxxxxxxxx>


> ---
>  restorecond/stringslist.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/restorecond/stringslist.c b/restorecond/stringslist.c
> index f9404b1..a76542a 100644
> --- a/restorecond/stringslist.c
> +++ b/restorecond/stringslist.c
> @@ -48,6 +48,8 @@ void strings_list_add(struct stringsList **list, const char *string)
>         if (!newptr)
>                 exitApp("Out of Memory");
>         newptr->string = strdup(string);
> +       if (!newptr->string)
> +               exitApp("Out of Memory");
>         newptr->next = ptr;
>         if (prev)
>                 prev->next = newptr;
> --
> 2.33.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