Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. #include <string.h>
  2. #include <stdlib.h>
  3. #include <stdio.h>
  4.  
  5. int main(int argc, char *argv[])
  6. {
  7. // creating buffer in heap
  8. char *buffer = (char*)malloc(16);
  9.  
  10. // copying the cli argument
  11. strcpy(buffer, argv[1]); // this is the dangerous line
  12.  
  13. printf("buffer size: 16\ninput size: %d\n", strlen(buffer));
  14.  
  15. // deallocating buffer
  16. free(buffer);
  17.  
  18. // return 0
  19. return 0;
  20.  
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement