- /******************************************************************************
- * version: 1.0
- * file: overflow_attack.cpp
- * date: 2014.07.14
- * description: 缓冲区溢出,溢出的字符串进入其他数组中
- * other:
- ******************************************************************************/
- #include <stdlib.h>
- #include <string.h>
- int main() {
- char pw[8] = "pass";
- char in[8];
- while (1) {
- scanf("%s", in);
- if (strcmp(in, pw) == 0) {
- printf("yes\\n");
- break;
- } else {
- printf("no\\n");
- }
- }
- system("pause");
- return 0;
- }
- /*
- * 测试结果:
- 11111111www
- no
- www
- yes
- *
- * */
- //该片段来自于http://www.codesnippet.cn/detail/0112201411105.html
来源: http://www.codesnippet.cn/detail/0112201411105.html