Demonstration of buffer overflow (缓冲区溢出的事例)

    xiaoxiao2023-11-08  160

    /* Demonstration of buffer overflow *///缓冲区溢出的示范 #include <stdio.h> #include <stdlib.h> /* Implementation of library function gets() */ char *gets(char *dest) /*指针函数*/ { int c = getchar(); /*从键盘输入一个字符赋给c*/ char *p = dest; while (c != EOF && c != '\n') { *p++ = c; c = getchar(); } *p = '\0'; return dest; } /* Read input line and write it back */ void echo() { char buf[4]; /* Way too small! */ gets(buf); puts(buf); } void call_echo() { echo(); } /*void smash() { printf("I've been smashed!\n"); exit(0); } */ int main() { printf("Type a string:"); call_echo(); return 0; } objdump -S a.out Disassembly of section .init: 08048354 <_init>: 8048354: 53 push
    转载请注明原文地址: https://yun.8miu.com/read-111348.html
    最新回复(0)