cybersecurity · intermediate · ~15 min
Allowlist instead of blocklist for command arguments.
Implement int is_safe_arg(const char *s) returning 1 if s is non-empty and contains only letters, digits, '.', '-', '_', '/', else 0 (an allowlist for a filename-like argument).
int is_safe_arg(const char *s) {
/* TODO */
return 0;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.