cybersecurity · beginner · ~15 min · safe pentest lab
Prefer exec-family over the shell.
Classify a process-launch function by whether it avoids the shell. The exec family takes an explicit argv and never invokes a shell, so there is no command-injection surface.
Implement int is_safer_exec(const char *fn) that returns 1 for the shell-free exec functions and 0 for the shell-invoking ones.
"execv" and "execve"."system" and "popen".fn: a NUL-terminated function name the grader passes.Returns int: 1 if fn is a shell-free exec function, else 0.
is_safer_exec("execv") -> 1
is_safer_exec("system") -> 0
is_safer_exec("popen") -> 0
A NUL-terminated function name fn.
An int: 1 for execv/execve, else 0.
Exact match; execv/execve -> 1, system/popen -> 0.
#include <string.h>
int is_safer_exec(const char *fn) {
/* TODO */
return 0;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.