From b0cf064f819357feedc77d6d5eb0de49e122554a Mon Sep 17 00:00:00 2001 From: marcinzelent Date: Sat, 16 Jun 2018 22:50:18 +0200 Subject: Added command injection example and secured examples --- examples/command-injection/command-injection.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 examples/command-injection/command-injection.c (limited to 'examples/command-injection') diff --git a/examples/command-injection/command-injection.c b/examples/command-injection/command-injection.c new file mode 100644 index 0000000..914b32e --- /dev/null +++ b/examples/command-injection/command-injection.c @@ -0,0 +1,12 @@ +#include +#include + +int main(int argc, char **argv) +{ + char cmd[strlen(argv[1]) + 6]; + strcpy(cmd, "echo "); + strcat(cmd, argv[1]); + system(cmd); + + return 0; +} -- cgit v1.2.3