Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <string.h>
- #include <stdlib.h>
- #include <stdio.h>
- int main(int argc, char *argv[])
- {
- // creating buffer in heap
- char *buffer = (char*)malloc(16);
- // copying the cli argument
- strcpy(buffer, argv[1]); // this is the dangerous line
- printf("buffer size: 16\ninput size: %d\n", strlen(buffer));
- // deallocating buffer
- free(buffer);
- // return 0
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement