diff options
author | Andrew G. Morgan <morgan@kernel.org> | 2021-06-21 17:46:43 -0700 |
---|---|---|
committer | Andrew G. Morgan <morgan@kernel.org> | 2021-06-21 17:46:43 -0700 |
commit | 06ec53d0c9fcddcc071a0e07731e6c83238400e6 (patch) | |
tree | 3b72224cb78968adfbb15ab98a62b0960571e60c | |
parent | 3857d17677ab60c35d12c003eee219c6f51da566 (diff) | |
download | libcap2-06ec53d0c9fcddcc071a0e07731e6c83238400e6.tar.gz |
Permit compilation with -std=c89.
Tested with
make COPTS="-O2 -std=c89" clean all test sudotest
This addresses the issue reported by Byron Stanoszek:
https://bugzilla.kernel.org/show_bug.cgi?id=213541
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
-rw-r--r-- | Makefile | 1 | ||||
-rw-r--r-- | libcap/cap_test.c | 1 | ||||
-rw-r--r-- | psx/psx.c | 2 | ||||
-rw-r--r-- | tests/exploit.c | 9 | ||||
-rw-r--r-- | tests/libcap_launch_test.c | 6 | ||||
-rw-r--r-- | tests/uns_test.c | 3 |
6 files changed, 15 insertions, 7 deletions
@@ -68,6 +68,7 @@ endif distcheck: ./distcheck.sh $(MAKE) DYNAMIC=yes clean all test sudotest + $(MAKE) DYNAMIC=no COPTS="-O2 -std=c89" clean all test sudotest $(MAKE) PAM_CAP=no CC=/usr/local/musl/bin/musl-gcc clean all test sudotest $(MAKE) clean all test sudotest $(MAKE) distclean diff --git a/libcap/cap_test.c b/libcap/cap_test.c index c9e83de..a717217 100644 --- a/libcap/cap_test.c +++ b/libcap/cap_test.c @@ -79,4 +79,5 @@ int main(int argc, char **argv) { exit(1); } printf("cap_test PASS\n"); + exit(0); } @@ -229,7 +229,7 @@ static void psx_syscall_start(void) { psx_tracker.psx_sig = SIGSYS; psx_confirm_sigaction(); - psx_do_registration(); // register the main thread. + psx_do_registration(); /* register the main thread. */ psx_tracker.initialized = 1; } diff --git a/tests/exploit.c b/tests/exploit.c index 28bac88..814337c 100644 --- a/tests/exploit.c +++ b/tests/exploit.c @@ -16,6 +16,10 @@ * to execute arbitrary code. As such, if all but one thread drops * privilege, privilege escalation is somewhat trivial. */ + +/* as per "man sigaction" */ +#define _POSIX_C_SOURCE 200809L + #include <pthread.h> #include <signal.h> #include <stdio.h> @@ -148,7 +152,8 @@ int main(int argc, char **argv) { if (greatest_len != 1) { printf("exploit succeeded\n"); exit(1); - } else { - printf("exploit failed\n"); } + + printf("exploit failed\n"); + exit(0); } diff --git a/tests/libcap_launch_test.c b/tests/libcap_launch_test.c index 6cbfc43..5286979 100644 --- a/tests/libcap_launch_test.c +++ b/tests/libcap_launch_test.c @@ -199,10 +199,10 @@ int main(int argc, char **argv) { cap_free(final); cap_free(orig); - if (success) { - printf("cap_launch_test: PASSED\n"); - } else { + if (!success) { printf("cap_launch_test: FAILED\n"); exit(1); } + printf("cap_launch_test: PASSED\n"); + exit(0); } diff --git a/tests/uns_test.c b/tests/uns_test.c index 41aa0a6..d8f5415 100644 --- a/tests/uns_test.c +++ b/tests/uns_test.c @@ -115,7 +115,8 @@ int main(int argc, char **argv) } close(fds.from[0]); - for (int i=0; i<2; i++) { + int i; + for (i=0; i<2; i++) { char *map_file; if (asprintf(&map_file, file_formats[i], pid) < 0) { perror("allocate string"); |