Skip to content

Instantly share code, notes, and snippets.

@sw17ch
sw17ch / gist:1901197
Created February 24, 2012 14:17 — forked from manlycode/gist:1896012
Can I use a buffer overflow exploit with this code, or is it secure?
int truncate_and_call(fn_ptr *fns, int index, char *user_string)
{
char buf[64];
// Truncate supplied string
strncpy(buf, user_string, sizeof(buf) - 1);
buf[sizeof(buf) - 1] = '\0';
return fns[index](buf);
}