Removal of the gets function
In C11, the famous gets
function is removed. The gets
function was subject to buffer overflow attacks, and in older versions it was decided to make the function deprecated. Later, as part of the C11 standard, it was removed. Therefore, older source code that uses the gets
function won't be compiled using a C11 compiler.
The fgets
function can be used instead of gets
. The following is an excerpt from the gets
manual page (man page) in macOS:
SECURITY CONSIDERATIONS
The gets() function cannot be used securely. Because of its lack of bounds checking, and the inability for the calling program to reliably determine the length of the next incoming line, the use of this function enables malicious users to arbitrarily change a running program's functionality through a buffer overflow attack. It is strongly suggested that the fgets() function be used in all cases. (See the FSA.)