diff mbox series

Check strdup() failure

Message ID alpine.LFD.2.21.1905102118010.16225@34-41-5D-CA-59-C7 (mailing list archive)
State Accepted
Headers show
Series Check strdup() failure | expand

Commit Message

Jokke Hämäläinen May 10, 2019, 6:18 p.m. UTC
---
 libselinux/utils/getconlist.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

William Roberts May 10, 2019, 9 p.m. UTC | #1
On Fri, May 10, 2019 at 12:04 PM Jokke Hämäläinen
<jokke.hamalainen@kolttonen.fi> 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
William Roberts May 16, 2019, 12:36 a.m. UTC | #2
merged: https://github.com/SELinuxProject/selinux/pull/149

On Fri, May 10, 2019 at 2:00 PM William Roberts
<bill.c.roberts@gmail.com> wrote:
>
> On Fri, May 10, 2019 at 12:04 PM Jokke Hämäläinen
> <jokke.hamalainen@kolttonen.fi> 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
diff mbox series

Patch

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);