我正在运行一个CTF比赛,目前正在编写一道涉及C语言gets
函数的题目。我知道这个函数已经被废弃且存在安全隐患,在其他情况下我绝对不会使用它。但是,当我使用gcc
编译我的代码并运行二进制文件时,当程序执行到gets
函数时,会出现一条友好的错误提示信息:
warning: this program uses gets(), which is unsafe.
这通常很好,因为它警告您获取不安全,但不幸的是,在我的CTF比赛中,我认为这个错误信息使问题变得太容易了。你知道我该如何禁用这个警告吗?谢谢!
$ gcc --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Apple clang version 11.0.3 (clang-1103.0.32.62)
Target: x86_64-apple-darwin19.4.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
gets
的东西吗?您可以编写基于fgets
(大约3-4行代码)或基于fgetc
(约5-6行代码)的不安全的mygets
。 - Jabberwockygets()
的程序。 - RobertS supports Monica Cellio