C++缓冲区溢出

mac2022-06-30  94

  测试代码:

#include <stdlib.h> #include <string.h> #include <stdio.h> int main() { char pw[8] ="pass"; char in[8]; while (1) { scanf("%s", in); if (strcmp(in, pw) == 0) { printf("yesn\n"); break; } else { printf("non\n"); } } return 0; }

  输入:11111111www

  输出:no

  输入:www

  输出:yes

  可以看到, 当我们输入www的时候, 却输出了yes, 逻辑上面是当用户输入的字符串是pass的时候, 才能输出yes ;

  

  参考:

    本文出处 :http://www.thinksaas.cn/topics/0/84/84726.html

    缓冲区溢出原理解析 :http://www.cnblogs.com/fanzhidongyzby/archive/2013/08/10/3250405.html

    安全漏洞是如何造成的:缓冲区溢出 :http://netsecurity.51cto.com/art/201509/490090.htm

转载于:https://www.cnblogs.com/diligenceday/p/6257853.html

相关资源:C 缓冲区溢出实验
最新回复(0)