cybersecurity · intermediate · ~15 min
Implement SQL single-quote escaping safely.
As a last resort, implement int escape_quotes(const char *in, char *out, int outsz) doubling every single quote (' -> ''), NUL-terminating, and returning the output length, or -1 if it wouldn't fit.
int escape_quotes(const char *in, char *out, int outsz) {
/* TODO */
return -1;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.