I created a program that is allocating 4 bytes of memory successively through a recursive function:
#include <stdio.h>
#include <stdlib.h>
#define BUF 2
void overflow(int payload){
payload = payload - 1;
int stack = (int)malloc(payload * sizeof(int));
payload = payload + 1;
overflow(payload);
}
int main(void){
overflow(BUF);
return 0;
}
It turns out that it stops working before it can consume all memory, would it be some kind of control of Windows itself to ensure system integrity, or is it a programming error?
How could I circumvent this and leave the program consuming memory to the top and when do I get to the top stop allocating memory?
I'm using windows 7 64 bit