cybersecurity · intermediate · ~15 min · safe pentest lab

Extract the CVE year

Parse a fixed-position field.

Challenge

Implement int cve_year(const char *s) returning the 4-digit year from a valid CVE-YYYY-NNNN id, or -1 if s doesn't start with CVE- followed by 4 digits.

Starter code

#include <string.h>

int cve_year(const char *s) {
    /* TODO */
    return -1;
}

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