strcat
Prototype
char* strcat(char* dest, const char* src);Vulnerable example
#include <stdio.h>
#include <string.h>
int main(int argc, char *argv[]) {
char buffer[10];
strlcpy(buffer, argv[1], sizeof(buffer));
// The strcat function concatenates the second string to the end of the first
// string. It does not check for buffer overflows, so if the first string is
// not large enough to hold the second string, it will write beyond the bounds
// of the buffer, potentially leading to a buffer overflow vulnerability.
strcat(buffer, argv[2]);
printf("%s\n", buffer);
return 0;
}Prevent
Last updated