Execve() for executing external programs


/ Published in: C
Save to your folder(s)

To execute external programs you should avoid functions like system() or popen() since they can be affected by the shell environment variables which issues serious security concerns. Instead, use execve().


Copy this code and paste it in your HTML
  1. #include <unistd.h>
  2. int main(int argc,char **argv){
  3. execve("/bin/ls", &argv[0], NULL);
  4. return 0;
  5. }

Report this snippet


Comments


You need to login to view comments.