I want to invoke a shell in C program by execve:
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
main()
{
char* path = "/bin/sh";
int err = execve(path, &path, NULL);
printf("%d\n", err);
printf("%s\n", strerror(errno));
printf("%x, %x\n", path, &path);
}
However the output is:
-1
Bad address
80485c0, bf816f4c
Because you aren’t sending a NULL terminated list of arguments.
You need: