Skip to content

Instantly share code, notes, and snippets.

@manlycode
Created February 24, 2012 00:14
Show Gist options
  • Save manlycode/1896012 to your computer and use it in GitHub Desktop.
Save manlycode/1896012 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