cybersecurity · intermediate · ~15 min

Does the path contain ..?

Detect path-traversal components.

Challenge

Implement int has_dotdot(const char *path) returning 1 if path contains the ".." sequence (a path-traversal indicator), else 0.

Starter code

#include <string.h>

int has_dotdot(const char *path) {
    /* TODO */
    return 0;
}

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