Fix buffer overflow with strcpy
This commit is contained in:
		
							parent
							
								
									ffcd96a6dd
								
							
						
					
					
						commit
						011236f238
					
				| @ -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]; | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user