SELinux Archive on lore.kernel.org
 help / color / 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	[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, back to index

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

SELinux Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/selinux/0 selinux/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 selinux selinux/ https://lore.kernel.org/selinux \
		selinux@vger.kernel.org selinux@archiver.kernel.org
	public-inbox-index selinux


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.selinux


AGPL code for this site: git clone https://public-inbox.org/ public-inbox