selinux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Check strdup() failure
@ 2019-05-10 18:18 Jokke Hämäläinen
  2019-05-10 21:00 ` William Roberts
  0 siblings, 1 reply; 3+ messages in thread
From: Jokke Hämäläinen @ 2019-05-10 18:18 UTC (permalink / raw)
  To: selinux



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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] Check strdup() failure
  2019-05-10 18:18 [PATCH] Check strdup() failure Jokke Hämäläinen
@ 2019-05-10 21:00 ` William Roberts
  2019-05-16  0:36   ` William Roberts
  0 siblings, 1 reply; 3+ messages in thread
From: William Roberts @ 2019-05-10 21:00 UTC (permalink / raw)
  To: Jokke Hämäläinen; +Cc: selinux

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Check strdup() failure
  2019-05-10 21:00 ` William Roberts
@ 2019-05-16  0:36   ` William Roberts
  0 siblings, 0 replies; 3+ messages in thread
From: William Roberts @ 2019-05-16  0:36 UTC (permalink / raw)
  To: Jokke Hämäläinen; +Cc: selinux

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-05-16  1:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-10 18:18 [PATCH] Check strdup() failure Jokke Hämäläinen
2019-05-10 21:00 ` William Roberts
2019-05-16  0:36   ` William Roberts

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).