Fix buffer overflow with strcpy

This commit is contained in:
Jesse Millwood 2024-10-30 14:27:26 -04:00
parent ffcd96a6dd
commit 011236f238

View File

@ -9,7 +9,7 @@
void reverse_str(char *str){
size_t len = strlen(str);
char *tmp = reinterpret_cast<char*>(malloc(len));
char *tmp = reinterpret_cast<char*>(malloc(len + 1));
strcpy(tmp, str);
for(unsigned int offset = 0; offset < len; ++offset){
str[offset] = tmp[len-offset-1];