Re: [PATCH] Check strdup() failure

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

 



On Fri, May 10, 2019 at 12:04 PM Jokke Hämäläinen
<jokke.hamalainen@xxxxxxxxxxxx> wrote:
>
>
>
> ---
>  libselinux/utils/getconlist.c | 5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/libselinux/utils/getconlist.c b/libselinux/utils/getconlist.c
> index 5ac0ca85..29c16640 100644
> --- a/libselinux/utils/getconlist.c
> +++ b/libselinux/utils/getconlist.c
> @@ -27,6 +27,11 @@ int main(int argc, char **argv)
>                 switch (opt) {
>                 case 'l':
>                         level = strdup(optarg);
> +                       if (!level) {
> +                               fprintf(stderr, "memory allocation failure: %d(%s)\n",
> +                                       errno, strerror(errno));
> +                               return 3;
> +                       }
>                         break;
>                 default:
>                         usage(argv[0], "invalid option", 1);
> --
> 2.21.0
>

ack




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

  Powered by Linux