Libsepol Mac Build Errors
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
PATCH 1/3 libsepol: fix unused variable 'size' on mac build
From: William Roberts <[email protected]>
Fix this on Mac build:
genbools.c:71:9: warning: unused variable 'size' [-Wunused-variable]
size_t size = 0;
^--- libsepol/src/genbools.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
libsepol/src/genbools.c +1 -1
@@ -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);
Signature · 1 line
1.9.1
PATCH 2/3 libsepol: fix unused variable 'len' on mac build
In reply to [email protected]From: William Roberts <[email protected]>
Fix this:
genusers.c:39:9: warning: unused variable 'len' [-Wunused-variable]
size_t len = 0;
--- libsepol/src/genusers.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
libsepol/src/genusers.c +1 -1
@@ -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
Signature · 1 line
1.9.1
PATCH 3/3 libsepol: fix unitialized variable 'nread' on mac build
In reply to [email protected]From: William Roberts <[email protected]>
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--- libsepol/src/genusers.c | 1 + 1 file changed, 1 insertion(+)
libsepol/src/genusers.c +1 -0
@@ -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 );
Signature · 1 line
1.9.1
Re: [PATCH 3/3] libsepol: fix unitialized variable 'nread' on mac build
Quoted 4 lines · On 09/23/2016 04:55 PM, [email protected] wrote:
From: William Roberts <[email protected]>
Fix this:
genusers.c:63:14: warning: variable 'nread' is uninitialized when used here [-Wuninitialized]
Quoted 8 lines
if (buffer[nread - 1] == '\n') ^~~~~ genusers.c:40:15: note: initialize the variable 'nread' to silence this warning ssize_t nread; ^ = 0Signed-off-by William Roberts <[email protected]>
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).
Quoted 17 lines
--- libsepol/src/genusers.c | 1 + 1 file changed, 1 insertion(+)libsepol/src/genusers.c +1
-0@@ -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 );
Quoted 9 lines · [email protected] 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.
Quoted 8 lines · Joshua Brindle
Quoted 7 lines · [email protected] 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?
Quoted 7 lines
Quoted 3 lines
[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.
Quoted 13 lines · William Roberts
Quoted 11 lines · Joshua Brindle
Quoted 9 lines · [email protected] 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
Quoted 6 lines
Quoted 2 lines
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 :)
Quoted 28 lines · Joshua Brindle
Quoted 17 lines · William Roberts
Quoted 14 lines · Joshua Brindle
Quoted 10 lines · [email protected] 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
Quoted 8 lines
Quoted 2 lines
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.
Quoted 6 lines
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.