Skip to content

Instantly share code, notes, and snippets.

@sw17ch
Forked from manlycode/gist:1896012
Created February 24, 2012 14:17
Show Gist options
  • Save sw17ch/1901197 to your computer and use it in GitHub Desktop.
Save sw17ch/1901197 to your computer and use it in GitHub Desktop.
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);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment