C11
& C++14
standards have dropped gets()
function that is inherently insecure & leads to security problems because it doesn't performs bounds checking results in buffer overflow. Then why C11
standard doesn't drop strcat()
& strcpy()
functions? strcat()
function doesn't check to see whether second string will fit in the 1st array. strcpy()
function also contains no provision for checking boundary of target array. What if the source array has more characters than destination array can hold? Most probably program will crash at runtime.
So, wouldn't it be nice if these two unsafe functions completely removed from the language? Why they are still exist? What is the reason? Wouldn't it is fine to have only functions like strncat(),strncpy()
? If I am not wrong Microsoft C & C++ compiler provides safe versions of these functions strcpy_s(),strcat_s()
. Then why they aren't officially implemented by other C compilers to provide safety?