C++緩沖區溢出


  測試代碼:

#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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM