gets에 대해서 이상한 함수가 계속 뜨는군요...(쉘프로그램을 짜

yanggak의 이미지

[st20013133@redserver st20013133]$ gcc -o shellex shell.c
/tmp/ccU1vD46.o: In function `readCommand':
/tmp/ccU1vD46.o(.text+0x2ff): the `gets' function is dangerous and should not be used.
[st20013133@redserver st20013133]$

쉘을 C로 구현하는 중인데 프롬프트를 띄우고 line을 읽어드릴려구...
gets를 썻는데 위와 같은 메시지가 자꾸 뜨네요...뭐떔에 그러지요?

sangwoo의 이미지

gets는 바운더리 체크가 없기 때문에, buffer overflow 가 일어나서, 여러 문제를
야기할 가능성이 큽니다. fgets를 이용하세요. :-)
..라는 이야기입니다 ^^

----
Let's shut up and code.