strcpy
Prototype
char * strcpy(char * dest, const char * src)Vulnerable example
#include <string.h>
int main(int argc, char* argv[])
{
char buffer[10];
strcpy(buffer, argv[1]);
return 0;
}Prevent
#include <string.h>
int main(int argc, char* argv[])
{
char buffer[10];
strlcpy(buffer, argv[1], sizeof(buffer));
return 0;
}Last updated