cybersecurity · intermediate · ~15 min

Does it create atomically?

Recognise the atomic-create defence.

Challenge

Implement int uses_excl(const char *flags) returning 1 if the open-flags string contains "O_EXCL" (atomic create that fails if the file exists), else 0.

Starter code

#include <string.h>

int uses_excl(const char *flags) {
    /* TODO */
    return 0;
}

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