warning:gets function is dangerous [duplicate]

2019-01-02 21:24发布

This question already has an answer here:

When i use gets function,gcc gives me a warning:

warning:the `gets' function is dangerous and should not be used.

Why gets and puts function dangerous?

标签: c
7条回答
十年一品温如言
2楼-- · 2019-01-02 21:54

Buffer overruns are dangerous. Here's the definition:

/* Get a line from the stdin stream. */
char *gets(char *buffer);

How big is the buffer? If a user types more data that can fit in the buffer, the program could crash and be susceptible to hacker exploits.

查看更多
登录 后发表回答