All of lore.kernel.org
 help / color / mirror / Atom feed
* Libsepol Mac Build Errors
@ 2016-09-23 20:55 william.c.roberts
  2016-09-23 20:55 ` [PATCH 1/3] libsepol: fix unused variable 'size' on mac build william.c.roberts
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: william.c.roberts @ 2016-09-23 20:55 UTC (permalink / raw)
  To: selinux, sds, brindle

The patches below fix some warnings reported by Josh Brindle on
the libsepol build.

Josh can you test these and see if those three warning go away
and give an ack if they are ok?

[PATCH 1/3] libsepol: fix unused variable 'size' on mac build
[PATCH 2/3] libsepol: fix unused variable 'len' on mac build
[PATCH 3/3] libsepol: fix unitialized variable 'nread' on mac build

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

* [PATCH 1/3] libsepol: fix unused variable 'size' on mac build
  2016-09-23 20:55 Libsepol Mac Build Errors william.c.roberts
@ 2016-09-23 20:55 ` william.c.roberts
  2016-09-23 20:55 ` [PATCH 2/3] libsepol: fix unused variable 'len' " william.c.roberts
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 9+ messages in thread
From: william.c.roberts @ 2016-09-23 20:55 UTC (permalink / raw)
  To: selinux, sds, brindle

From: William Roberts <william.c.roberts@intel.com>

Fix this on Mac build:
genbools.c:71:9: warning: unused variable 'size' [-Wunused-variable]
        size_t size = 0;
               ^
Signed-off-by: William Roberts <william.c.roberts@intel.com>
---
 libsepol/src/genbools.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libsepol/src/genbools.c b/libsepol/src/genbools.c
index c81e848..c1f5405 100644
--- a/libsepol/src/genbools.c
+++ b/libsepol/src/genbools.c
@@ -68,7 +68,6 @@ static int load_booleans(struct policydb *policydb, const char *path,
 {
 	FILE *boolf;
 	char *buffer = NULL;
-	size_t size = 0;
 	char localbools[BUFSIZ];
 	char name[BUFSIZ];
 	int val;
@@ -87,6 +86,7 @@ static int load_booleans(struct policydb *policydb, const char *path,
 
         while(fgets(buffer, 255, boolf) != NULL) {
 #else
+	size_t size = 0;
 	while (getline(&buffer, &size, boolf) > 0) {
 #endif
 		int ret = process_boolean(buffer, name, sizeof(name), &val);
-- 
1.9.1

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

* [PATCH 2/3] libsepol: fix unused variable 'len' on mac build
  2016-09-23 20:55 Libsepol Mac Build Errors william.c.roberts
  2016-09-23 20:55 ` [PATCH 1/3] libsepol: fix unused variable 'size' on mac build william.c.roberts
@ 2016-09-23 20:55 ` william.c.roberts
  2016-09-23 20:55 ` [PATCH 3/3] libsepol: fix unitialized variable 'nread' " william.c.roberts
  2016-09-24  1:10 ` Libsepol Mac Build Errors Joshua Brindle
  3 siblings, 0 replies; 9+ messages in thread
From: william.c.roberts @ 2016-09-23 20:55 UTC (permalink / raw)
  To: selinux, sds, brindle

From: William Roberts <william.c.roberts@intel.com>

Fix this:
genusers.c:39:9: warning: unused variable 'len' [-Wunused-variable]
        size_t len = 0;

Signed-off-by: William Roberts <william.c.roberts@intel.com>
---
 libsepol/src/genusers.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libsepol/src/genusers.c b/libsepol/src/genusers.c
index 0b98a76..57a9a2e 100644
--- a/libsepol/src/genusers.c
+++ b/libsepol/src/genusers.c
@@ -36,7 +36,6 @@ static int load_users(struct policydb *policydb, const char *path)
 {
 	FILE *fp;
 	char *buffer = NULL, *p, *q, oldc;
-	size_t len = 0;
 	ssize_t nread;
 	unsigned lineno = 0, islist = 0, bit;
 	user_datum_t *usrdatum;
@@ -55,6 +54,7 @@ static int load_users(struct policydb *policydb, const char *path)
 
 	while(fgets(buffer, 255, fp) != NULL) {
 #else
+	size_t len = 0;
 	__fsetlocking(fp, FSETLOCKING_BYCALLER);
 	while ((nread = getline(&buffer, &len, fp)) > 0) {
 #endif
-- 
1.9.1

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

* [PATCH 3/3] libsepol: fix unitialized variable 'nread' on mac build
  2016-09-23 20:55 Libsepol Mac Build Errors william.c.roberts
  2016-09-23 20:55 ` [PATCH 1/3] libsepol: fix unused variable 'size' on mac build william.c.roberts
  2016-09-23 20:55 ` [PATCH 2/3] libsepol: fix unused variable 'len' " william.c.roberts
@ 2016-09-23 20:55 ` william.c.roberts
  2016-09-26 14:37   ` Stephen Smalley
  2016-09-24  1:10 ` Libsepol Mac Build Errors Joshua Brindle
  3 siblings, 1 reply; 9+ messages in thread
From: william.c.roberts @ 2016-09-23 20:55 UTC (permalink / raw)
  To: selinux, sds, brindle

From: William Roberts <william.c.roberts@intel.com>

Fix this:
genusers.c:63:14: warning: variable 'nread' is uninitialized when used here [-Wuninitialized]
                if (buffer[nread - 1] == '\n')
                           ^~~~~
genusers.c:40:15: note: initialize the variable 'nread' to silence this warning
        ssize_t nread;
                     ^
                      = 0

Signed-off-by: William Roberts <william.c.roberts@intel.com>
---
 libsepol/src/genusers.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libsepol/src/genusers.c b/libsepol/src/genusers.c
index 57a9a2e..5568210 100644
--- a/libsepol/src/genusers.c
+++ b/libsepol/src/genusers.c
@@ -53,6 +53,7 @@ static int load_users(struct policydb *policydb, const char *path)
 	}
 
 	while(fgets(buffer, 255, fp) != NULL) {
+		nread = strlen(buffer);
 #else
 	size_t len = 0;
 	__fsetlocking(fp, FSETLOCKING_BYCALLER);
-- 
1.9.1

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

* Re: Libsepol Mac Build Errors
  2016-09-23 20:55 Libsepol Mac Build Errors william.c.roberts
                   ` (2 preceding siblings ...)
  2016-09-23 20:55 ` [PATCH 3/3] libsepol: fix unitialized variable 'nread' " william.c.roberts
@ 2016-09-24  1:10 ` Joshua Brindle
  2016-09-24  1:39   ` William Roberts
  3 siblings, 1 reply; 9+ messages in thread
From: Joshua Brindle @ 2016-09-24  1:10 UTC (permalink / raw)
  To: william.c.roberts; +Cc: selinux, sds

william.c.roberts@intel.com wrote:
> The patches below fix some warnings reported by Josh Brindle on
> the libsepol build.
>
> Josh can you test these and see if those three warning go away
> and give an ack if they are ok?
>
> [PATCH 1/3] libsepol: fix unused variable 'size' on mac build
> [PATCH 2/3] libsepol: fix unused variable 'len' on mac build
> [PATCH 3/3] libsepol: fix unitialized variable 'nread' on mac build

That fixed the build errors. The linker does not like the soname, 
version map, etc stuff though so I still don't get a sofile out.

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

* Re: Libsepol Mac Build Errors
  2016-09-24  1:10 ` Libsepol Mac Build Errors Joshua Brindle
@ 2016-09-24  1:39   ` William Roberts
  2016-09-24  1:42     ` Joshua Brindle
  0 siblings, 1 reply; 9+ messages in thread
From: William Roberts @ 2016-09-24  1:39 UTC (permalink / raw)
  To: Joshua Brindle; +Cc: William Roberts, Stephen Smalley, selinux

On Fri, Sep 23, 2016 at 6:10 PM, Joshua Brindle
<brindle@quarksecurity.com> wrote:
> william.c.roberts@intel.com wrote:
>>
>> The patches below fix some warnings reported by Josh Brindle on
>> the libsepol build.
>>
>> Josh can you test these and see if those three warning go away
>> and give an ack if they are ok?
>>
>> [PATCH 1/3] libsepol: fix unused variable 'size' on mac build
>> [PATCH 2/3] libsepol: fix unused variable 'len' on mac build
>> [PATCH 3/3] libsepol: fix unitialized variable 'nread' on mac build
>
>
> That fixed the build errors. The linker does not like the soname, version
> map, etc stuff though so I still don't get a sofile out.

FYI I managed to set up macincloud today, so I have an el capitain instance
with 8 cores and 16GB ram I can use for testing. I'm currently syncing the
source tree, so ill be able to test on mac.

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

* Re: Libsepol Mac Build Errors
  2016-09-24  1:39   ` William Roberts
@ 2016-09-24  1:42     ` Joshua Brindle
  2016-09-24  1:51       ` William Roberts
  0 siblings, 1 reply; 9+ messages in thread
From: Joshua Brindle @ 2016-09-24  1:42 UTC (permalink / raw)
  To: William Roberts; +Cc: William Roberts, Stephen Smalley, selinux

William Roberts wrote:
> On Fri, Sep 23, 2016 at 6:10 PM, Joshua Brindle
> <brindle@quarksecurity.com>  wrote:
>> william.c.roberts@intel.com wrote:
>>> The patches below fix some warnings reported by Josh Brindle on
>>> the libsepol build.
>>>
>>> Josh can you test these and see if those three warning go away
>>> and give an ack if they are ok?
>>>
>>> [PATCH 1/3] libsepol: fix unused variable 'size' on mac build
>>> [PATCH 2/3] libsepol: fix unused variable 'len' on mac build
>>> [PATCH 3/3] libsepol: fix unitialized variable 'nread' on mac build
>>
>> That fixed the build errors. The linker does not like the soname, version
>> map, etc stuff though so I still don't get a sofile out.
>
> FYI I managed to set up macincloud today, so I have an el capitain instance
> with 8 cores and 16GB ram I can use for testing. I'm currently syncing the
> source tree, so ill be able to test on mac.

Well that is neat.

FWIW I have an Android tree but I was building your selinux repo outside 
of Android. I personally keep around darwin libsepol.so files built out 
of Android for use with setools 4 since it works on Mac's now so I 
appreciate any work to make it work better on Mac :)

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

* Re: Libsepol Mac Build Errors
  2016-09-24  1:42     ` Joshua Brindle
@ 2016-09-24  1:51       ` William Roberts
  0 siblings, 0 replies; 9+ messages in thread
From: William Roberts @ 2016-09-24  1:51 UTC (permalink / raw)
  To: Joshua Brindle; +Cc: William Roberts, Stephen Smalley, selinux

On Fri, Sep 23, 2016 at 6:42 PM, Joshua Brindle
<brindle@quarksecurity.com> wrote:
> William Roberts wrote:
>>
>> On Fri, Sep 23, 2016 at 6:10 PM, Joshua Brindle
>> <brindle@quarksecurity.com>  wrote:
>>>
>>> william.c.roberts@intel.com wrote:
>>>>
>>>> The patches below fix some warnings reported by Josh Brindle on
>>>> the libsepol build.
>>>>
>>>> Josh can you test these and see if those three warning go away
>>>> and give an ack if they are ok?
>>>>
>>>> [PATCH 1/3] libsepol: fix unused variable 'size' on mac build
>>>> [PATCH 2/3] libsepol: fix unused variable 'len' on mac build
>>>> [PATCH 3/3] libsepol: fix unitialized variable 'nread' on mac build
>>>
>>>
>>> That fixed the build errors. The linker does not like the soname, version
>>> map, etc stuff though so I still don't get a sofile out.
>>
>>
>> FYI I managed to set up macincloud today, so I have an el capitain
>> instance
>> with 8 cores and 16GB ram I can use for testing. I'm currently syncing the
>> source tree, so ill be able to test on mac.
>
>
> Well that is neat.
>
> FWIW I have an Android tree but I was building your selinux repo outside of
> Android. I personally keep around darwin libsepol.so files built out of
> Android for use with setools 4 since it works on Mac's now so I appreciate
> any work to make it work better on Mac :)

I cant believe that code was actually working, nread was used uninitialized
for accessing memory locations within an array.

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

* Re: [PATCH 3/3] libsepol: fix unitialized variable 'nread' on mac build
  2016-09-23 20:55 ` [PATCH 3/3] libsepol: fix unitialized variable 'nread' " william.c.roberts
@ 2016-09-26 14:37   ` Stephen Smalley
  0 siblings, 0 replies; 9+ messages in thread
From: Stephen Smalley @ 2016-09-26 14:37 UTC (permalink / raw)
  To: william.c.roberts, selinux, brindle

On 09/23/2016 04:55 PM, william.c.roberts@intel.com wrote:
> From: William Roberts <william.c.roberts@intel.com>
> 
> Fix this:
> genusers.c:63:14: warning: variable 'nread' is uninitialized when used here [-Wuninitialized]
>                 if (buffer[nread - 1] == '\n')
>                            ^~~~~
> genusers.c:40:15: note: initialize the variable 'nread' to silence this warning
>         ssize_t nread;
>                      ^
>                       = 0
> 
> Signed-off-by: William Roberts <william.c.roberts@intel.com>

Thanks, applied all 3 patches.
NB none of this code is actually used on the Mac or elsewhere in Android
for that matter, and even on Linux, it is just legacy code (not used in
modern distributions).

> ---
>  libsepol/src/genusers.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/libsepol/src/genusers.c b/libsepol/src/genusers.c
> index 57a9a2e..5568210 100644
> --- a/libsepol/src/genusers.c
> +++ b/libsepol/src/genusers.c
> @@ -53,6 +53,7 @@ static int load_users(struct policydb *policydb, const char *path)
>  	}
>  
>  	while(fgets(buffer, 255, fp) != NULL) {
> +		nread = strlen(buffer);
>  #else
>  	size_t len = 0;
>  	__fsetlocking(fp, FSETLOCKING_BYCALLER);
> 

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

end of thread, other threads:[~2016-09-26 14:37 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-23 20:55 Libsepol Mac Build Errors william.c.roberts
2016-09-23 20:55 ` [PATCH 1/3] libsepol: fix unused variable 'size' on mac build william.c.roberts
2016-09-23 20:55 ` [PATCH 2/3] libsepol: fix unused variable 'len' " william.c.roberts
2016-09-23 20:55 ` [PATCH 3/3] libsepol: fix unitialized variable 'nread' " william.c.roberts
2016-09-26 14:37   ` Stephen Smalley
2016-09-24  1:10 ` Libsepol Mac Build Errors Joshua Brindle
2016-09-24  1:39   ` William Roberts
2016-09-24  1:42     ` Joshua Brindle
2016-09-24  1:51       ` William Roberts

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.