Skip to content

Instantly share code, notes, and snippets.

@masbog
Created March 25, 2017 20:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save masbog/2ef3534dad3a654365ce4384f70325c6 to your computer and use it in GitHub Desktop.
Save masbog/2ef3534dad3a654365ce4384f70325c6 to your computer and use it in GitHub Desktop.
Mobile Top 10 2016-M7-Poor Code Quality example (buffer overflows, format string vulnerabilities)
int main(int argc, char **argv)
{
char text[1024];
static int some_value = -72;
strcpy(text, argv[1]); /* ignore the buffer overflow here */
printf("This is how you print correctly:\n");
printf("%s", text);
printf("This is how not to print:\n");
printf(text);
printf("some_value @ 0x%08x = %d [0x%08x]", &some_value, some_value, some_value);
return(0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment