selinux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Richard Haines <richard_c_haines@btinternet.com>
To: selinux@vger.kernel.org, nicolas.iooss@m4x.org
Cc: Richard Haines <richard_c_haines@btinternet.com>
Subject: [PATCH V2] libselinux: Fix security_get_boolean_names build error
Date: Mon,  8 Jul 2019 14:37:01 +0100	[thread overview]
Message-ID: <20190708133701.32317-1-richard_c_haines@btinternet.com> (raw)

When running 'make' from libselinux on Fedora 30 (gcc 9.1.1) the
following error is reported:

bute=const -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -Wstrict-overflow=5
-I../include -D_GNU_SOURCE  -DNO_ANDROID_BACKEND  -c -o booleans.o
booleans.c
booleans.c: In function ‘security_get_boolean_names’:
booleans.c:39:5: error: assuming signed overflow does not occur when
changing X +- C1 cmp C2 to X cmp C2 -+ C1 [-Werror=strict-overflow]
  39 | int security_get_boolean_names(char ***names, int *len)
      |    ^~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make[1]: *** [Makefile:171: booleans.o] Error 1

This is caused by the '--i' in the: 'for (--i; i >= 0; --i)' loop.

Signed-off-by: Richard Haines <richard_c_haines@btinternet.com>
---
V2 Change: Simplify the free loop.

 libselinux/src/booleans.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/libselinux/src/booleans.c b/libselinux/src/booleans.c
index ab1e0754..a9154ce8 100644
--- a/libselinux/src/booleans.c
+++ b/libselinux/src/booleans.c
@@ -81,8 +81,10 @@ int security_get_boolean_names(char ***names, int *len)
 	free(namelist);
 	return rc;
       bad_freen:
-	for (--i; i >= 0; --i)
-		free(n[i]);
+	if (i > 0) {
+		while (i >= 1)
+			free(n[--i]);
+	}
 	free(n);
       bad:
 	goto out;
-- 
2.21.0


             reply	other threads:[~2019-07-08 13:37 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-08 13:37 Richard Haines [this message]
2019-07-21 22:53 ` [PATCH V2] libselinux: Fix security_get_boolean_names build error Nicolas Iooss

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=20190708133701.32317-1-richard_c_haines@btinternet.com \
    --to=richard_c_haines@btinternet.com \
    --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).