setrlimit01.c: use a more reliable segfault
PATCH 1/1 setrlimit01.c: use a more reliable segfault
When compiled for Android, strcpying to the null pointer was being optimized away as unreachable, so the segfault wasn't being thrown. Use raise to throw the segfault instead of ub, since the test just needs the signal.
Signed-off-by Edward Liaw <[email protected]>
--- testcases/kernel/syscalls/setrlimit/setrlimit01.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
testcases/kernel/syscalls/setrlimit/setrlimit01.c +2 -2
@@ -33,6 +33,7 @@#include <sys/wait.h> #include <errno.h> #include <fcntl.h> +#include <signal.h> #include <stdlib.h> #include <unistd.h> #include "test.h"
@@ -256,8 +257,7 @@ static void test4(void)tst_brkm (TBROK , cleanup,"fork() failed" );if (pid ==0 ) {/* child */ -char *testbuf =NULL ; -strcpy (testbuf,"abcd" ); +raise (SIGSEGV );exit (0 ); }wait (&status);
Signature · 5 lines
2.48.1.711.g2feabab25a-goog -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi!
obviously correct and merged. It would be nice to rewrite this test with new API because it looks pretty ancient and there's a big margin of improvement.
Reviewed-by Andrea Cervesato <[email protected]>
Best regards,
Andrea Cervesato
Quoted 32 lines · Edward Liaw via ltp
When compiled for Android, strcpying to the null pointer was being optimized away as unreachable, so the segfault wasn't being thrown. Use raise to throw the segfault instead of ub, since the test just needs the signal.
Signed-off-by Edward Liaw <[email protected]>--- testcases/kernel/syscalls/setrlimit/setrlimit01.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)testcases/kernel/syscalls/setrlimit/setrlimit01.c +2
-2@@ -33,6 +33,7 @@#include <sys/wait.h> #include <errno.h> #include <fcntl.h> +#include <signal.h> #include <stdlib.h> #include <unistd.h> #include "test.h" @@ -256,8 +257,7 @@ static void test4(void)tst_brkm (TBROK , cleanup,"fork() failed" );if (pid ==0 ) {/* child */ -char *testbuf =NULL ; -strcpy (testbuf,"abcd" ); +raise (SIGSEGV );exit (0 ); }wait (&status);
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp