cybersecurity · intermediate · ~15 min

Detect world-writable files

`stat` and POSIX permission bits.

Challenge

Implement int is_world_writable(const char *path) returning 1 if the file at path has the world-writable bit set (S_IWOTH), 0 if not, and -1 if stat fails.

Starter code

#include <sys/stat.h>

int is_world_writable(const char *path) {
    /* TODO */
    return -1;
}

Solve this exercise in the browser editor — compile and run against the test harness, no setup required.