I am trying to demonstrate buffer overflow in strcmp
funcion in C.
I have strcpyV.c
file:
#include <stdio.h>
#include <string.h>
int main(int argc, char *argv[])
{
char a[8];
char b[8];
// function causes buffer overflow
strcpy(b, "01234567");
// buffer overflow again
strcpy(a, "89abcdef");
printf("\nb = %s\n", b);
return 0;
}
I compile this program using gcc compiler.
gcc -o strcpyV strcpyV.c
When I do this in raspberry py B+ (Raspbian wheezy) and run:
./strcpyV
I get expected result:
b = 0123456789abcdef
But when I do this whole process in Ubuntu 16.04 result is:
b = 01234567
Is there any way how to compile code without this memory protection?