target_vuln_code.c 391 B

1234567891011121314151617
  1. #include <stdio.h>
  2. #include <string.h>
  3. void vulnerable_function(char *input) {
  4. char buffer[256];
  5. printf(input);
  6. strncpy(buffer, input, sizeof(buffer) - 1);
  7. buffer[sizeof(buffer) - 1] = '\0';
  8. printf("\nInput processed: %s\n", buffer);
  9. }
  10. int test() {
  11. char malicious_input[] = "Hello World! %x %x %x %x\n";
  12. vulnerable_function(malicious_input);
  13. return 0;
  14. }