http://stackoverflow.com/questions/7423691/is-gets-officially-deprecated
Because it is impossible to tell without knowing the data in advance how many charac‐ters gets() will read, and because gets() will continue to store characters past the end of the buffer, it is extremely dangerous to use. It has been used to break computer security.
서비스로 manpage
ECURITY 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 func-
tionality through a buffer overflow attack. It is strongly suggested
that the fgets() function be used in all cases. (See the FSA.)
한마디로 요약하면 컴퓨터를 씹창 내고 싶으면 gets()를 쓰면 된다는거군...
내가 잘 몰라서그러는대 그럼 gets()로 쌓인 버퍼를 그때마다 지워주면 되는거아님?
입력 버퍼에 쓰인 내용이 버퍼보다 크면 경계 신경 안쓰고 그냥 무식하게 때려 박는다는 소린데, fgets쓰면 문제없을거같음.
버퍼보다 크면 -> 입력받는 변수의 사이즈보다 크면
그닥 씹창 까지는..
fflush() 를 알고 쓰면 문제는 없는건데, 그럴바에 차라리 fgets쓰는게 낫지않나
버퍼를 존나크게 하던가
지나가는 뉴비인데.... 버퍼고 나발이고 어짜피 프로그램 재시작하면 다 초기화 되는거 아님?
그럼 왜 만든거죠?
옛날에 쓰려고