cybersecurity · beginner · ~15 min · safe pentest lab
Recognise parameterized queries.
Recognise a parameterised SQL query by the presence of a ? placeholder — the marker that the driver will bind values separately instead of interpolating them as text.
Implement int uses_placeholder(const char *query) that returns 1 if query contains a ? placeholder, and 0 otherwise.
query: a NUL-terminated SQL query string the grader provides.Returns 1 if a ? appears in the query, 0 otherwise.
uses_placeholder("SELECT * FROM u WHERE id = ?") -> 1
uses_placeholder("SELECT * FROM u WHERE id = 5") -> 0
? returns 0.A NUL-terminated SQL query string.
1 if the query contains a '?' placeholder; otherwise 0.
Look for a '?' character.
#include <string.h>
int uses_placeholder(const char *query) {
/* TODO */
return 0;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.