From: Michael Tremer Date: Tue, 13 Dec 2022 11:02:02 +0000 (+0000) Subject: tests: command: Add a command that immediately causes SEGV X-Git-Tag: 0.9.29~421 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=663ad6a1fd40986e6d652e8ae6d734c98e8ff476;p=pakfire.git tests: command: Add a command that immediately causes SEGV Signed-off-by: Michael Tremer --- diff --git a/tests/stub/command.c b/tests/stub/command.c index 9549ebc0a..42d005cb3 100644 --- a/tests/stub/command.c +++ b/tests/stub/command.c @@ -363,6 +363,18 @@ static int _pipe(int argc, char* argv[]) { return 0; } +/* + Causes a segmentation fault so this program is being terminated +*/ +static int _segv(int argc, char* argv[]) { + char* p = NULL; + + // Storing a value to the NULL pointer + *p = 'a'; + + return 0; +} + int main(int argc, char* argv[]) { if (argc < 2) { fprintf(stderr, "No command given\n"); @@ -414,6 +426,10 @@ int main(int argc, char* argv[]) { else if (strcmp(command, "print-pid") == 0) callback = print_pid; + // SEGV + else if (strcmp(command, "segv") == 0) + callback = _segv; + // Send signal else if (strcmp(command, "send-signal") == 0) callback = send_signal;