cybersecurity · intermediate · ~15 min · safe pentest lab

Extract the request path

Pull the path out of a request line.

Challenge

Implement int request_path(const char *line, char *out, int outsz) copying the second token (path) of METHOD PATH VERSION into out, returning its length, or -1 if there aren't two spaces.

Starter code

#include <string.h>

int request_path(const char *line, char *out, int outsz) {
    /* TODO */
    return -1;
}

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