cybersecurity · intermediate · ~15 min

Detect SQL metacharacters

Spot characters used in SQL injection.

Challenge

Implement int has_sql_meta(const char *s) returning 1 if s contains a single quote, double quote, semicolon, or the comment marker "--", else 0.

Starter code

#include <string.h>

int has_sql_meta(const char *s) {
    /* TODO */
    return 0;
}

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