From: Stephen Smalley <sds@tycho.nsa.gov>
To: Nicolas Iooss <nicolas.iooss@m4x.org>, selinux@vger.kernel.org
Subject: Re: [PATCH 2/2] libsemanage/tests: check that string pointers are not NULL before comparing them
Date: Tue, 1 Oct 2019 15:02:25 -0400 [thread overview]
Message-ID: <73a29991-27d0-7d95-f728-3adb92c1bf48@tycho.nsa.gov> (raw)
In-Reply-To: <20190930202211.781578-2-nicolas.iooss@m4x.org>
On 9/30/19 4:22 PM, Nicolas Iooss wrote:
> This silences many issues reported by Infer static analyzer about
> possible NULL pointer dereferences.
>
> Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
Thanks, both applied.
> ---
> libsemanage/tests/test_utilities.c | 10 ++++++++++
> 1 file changed, 10 insertions(+)
>
> diff --git a/libsemanage/tests/test_utilities.c b/libsemanage/tests/test_utilities.c
> index fa3a077f5e92..33609401920c 100644
> --- a/libsemanage/tests/test_utilities.c
> +++ b/libsemanage/tests/test_utilities.c
> @@ -145,16 +145,19 @@ void test_semanage_split_on_space(void)
> return;
> }
> temp = semanage_split_on_space(str);
> + CU_ASSERT_PTR_NOT_NULL_FATAL(temp);
> CU_ASSERT_STRING_EQUAL(temp, "bar baz");
> free(str);
> str = temp;
>
> temp = semanage_split_on_space(str);
> + CU_ASSERT_PTR_NOT_NULL_FATAL(temp);
> CU_ASSERT_STRING_EQUAL(temp, "baz");
> free(str);
> str = temp;
>
> temp = semanage_split_on_space(str);
> + CU_ASSERT_PTR_NOT_NULL_FATAL(temp);
> CU_ASSERT_STRING_EQUAL(temp, "");
> free(str);
> free(temp);
> @@ -171,21 +174,25 @@ void test_semanage_split(void)
> return;
> }
> temp = semanage_split(str, NULL);
> + CU_ASSERT_PTR_NOT_NULL_FATAL(temp);
> CU_ASSERT_STRING_EQUAL(temp, "foo2 foo:bar:");
> free(str);
> str = temp;
>
> temp = semanage_split(str, "");
> + CU_ASSERT_PTR_NOT_NULL_FATAL(temp);
> CU_ASSERT_STRING_EQUAL(temp, "foo:bar:");
> free(str);
> str = temp;
>
> temp = semanage_split(str, ":");
> + CU_ASSERT_PTR_NOT_NULL_FATAL(temp);
> CU_ASSERT_STRING_EQUAL(temp, "bar:");
> free(str);
> str = temp;
>
> temp = semanage_split(str, ":");
> + CU_ASSERT_PTR_NOT_NULL_FATAL(temp);
> CU_ASSERT_STRING_EQUAL(temp, "");
> free(str);
> free(temp);
> @@ -301,14 +308,17 @@ void test_semanage_findval(void)
> CU_FAIL_FATAL("Temporary file was not created, aborting test.");
> }
> tok = semanage_findval(fname, "one", NULL);
> + CU_ASSERT_PTR_NOT_NULL_FATAL(tok);
> CU_ASSERT_STRING_EQUAL(tok, "");
> free(tok);
> rewind(fptr);
> tok = semanage_findval(fname, "one", "");
> + CU_ASSERT_PTR_NOT_NULL_FATAL(tok);
> CU_ASSERT_STRING_EQUAL(tok, "");
> free(tok);
> rewind(fptr);
> tok = semanage_findval(fname, "sigma", "=");
> + CU_ASSERT_PTR_NOT_NULL_FATAL(tok);
> CU_ASSERT_STRING_EQUAL(tok, "foo");
> free(tok);
> }
>
prev parent reply other threads:[~2019-10-01 19:02 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-30 20:22 [PATCH 1/2] libsemanage/tests: return when str is NULL Nicolas Iooss
2019-09-30 20:22 ` [PATCH 2/2] libsemanage/tests: check that string pointers are not NULL before comparing them Nicolas Iooss
2019-10-01 19:02 ` Stephen Smalley [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=73a29991-27d0-7d95-f728-3adb92c1bf48@tycho.nsa.gov \
--to=sds@tycho.nsa.gov \
--cc=nicolas.iooss@m4x.org \
--cc=selinux@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).