LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 869|回复: 6

写了一个菜程序,但在终端老是出一些提示,英文不好不明白是什么意思?

[复制链接]
发表于 2003-8-2 14:29:06 | 显示全部楼层 |阅读模式
源程序:

  1. #include<stdio.h>
  2. #define MAX 81

  3. int main(void)
  4. {
  5.         char name[MAX];
  6.         printf("Hi,What's your name?\n");
  7.         gets(name);
  8.         printf("Nice name,%s.\n",name);
  9. return 0;
  10. }


复制代码

每次都出现下面的提示,但可以正确运行程序,高手帮看一下是怎么回事。
[root@localhost cai]# gcc y1.c
/tmp/ccYFUbd1.o(.text+0x28): In function `main':
: the `gets' function is dangerous and should not be used.
发表于 2003-8-2 14:40:35 | 显示全部楼层
在函数'main'中
:‘get’ 是一个危险的函数,不应该使用。

至于危险的原因,我想应该是缓冲区溢出的问题。
发表于 2003-8-2 14:46:27 | 显示全部楼层
用fgets代替。
 楼主| 发表于 2003-8-2 15:29:36 | 显示全部楼层
谢谢!
发表于 2003-8-2 19:29:16 | 显示全部楼层
: the `gets' function is dangerous and should not be used.

don't understand this sentence, really bad English.
or maybe just don't understand why dangerous?
发表于 2003-8-2 22:49:29 | 显示全部楼层
function "gets()" 没有溢出检测,so its dangerous.
发表于 2003-8-4 13:22:26 | 显示全部楼层
这个函数存在缓冲区漏洞(可能被黑客利用),还有象scanf(),strcat(),strcpy()等也存在。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表