I stumbled upon an assembly programming challenge where I need to find why the following code gives a Bus Error when trying to run it. After much googling, I still can't figure out why.. My understanding of assembly x86 not great, any tips on finding the solution would be very appreciated.
Here is the code:
#include <stdlib.h>
int main(void) {
asm("pushf\n"
"orl $ 0x40000, (%esp)\n"
"popf\n");
*((int*) (((char*) malloc(5)) + 1)) = 23; // This line causes the Bus Error
return 0;
}