I have faced a compiler error(c3861) in my newly installed Visual studio community 2015 IDE:
I just want to use gets() function from stdio.h library, a
if you are looking forward to learn
about
buffer overflow vulnerability
you simply can use it and anther unsafe functions by the fallowing steps
Compile As
value to Compile as C Code (/TC)
disable specific warning
gets
and_getws
are removed from the beginning of vs 2015 because these functions are obsolete.
Alternative functions are gets_s
and _getws_s
.
The gets
function was considered too dangerous (because it can easily cause a buffer overflow), so it was removed from the latest revisions of both C and C++.
You are supposed to use fgets
instead. With that function you can limit input to the size of your buffer.
Since C11, gets
is replaced by gets_s
. The gets() function does not perform bounds checking, therefore this function is extremely vulnerable to buffer-overflows. The recommended replacements are gets_s()
or fgets()
gets_s(buf);
fgets(buf, sizeof(buf), stdin);