Tuesday, January 25, 2022

Overflow in C code

 #include<stdio.h>
#include<string.h>
#include<stdlib.h>

void overflow_function( char *str)
{
    char buffer[20];
    strcpy(buffer,str);
}

int main()
{
    char big_string[128];
    int i;
    for ( i=0 ; i<128 ; i++ ) {
             printf("%d\n",i);
             big_string[i] = 'A';  //fill the big_string with AAAAA's
    }
overflow_function(big_string);

getchar();

exit(0);

}