I don't know much about hacking, c, assembly, memory and all that stuff so I coudln't resolve my question by my self.
So, buffer overflow overflows into other address of variables and corrupts them. So I tested and it really does. And I thought that if it can overflow constant variable buffer overflow must be super powered and I tested, but it doesn't overflow const variable.
Why is that?
int a;
char buffer[8];
and
const int a;
char buffer[8];
has address of variable 'buffer' in front of address of variable 'a' by size of the 'buffer'. Is there something special in const variable when allocated to a memory?
my sample code:
#include <stdio.h>
#include <string.h>
int main() {
char buffer1[8];
const int a=0; //vs int a=0;
char buffer2[8];
strcpy(buffer1,"one");
strcpy(buffer2,"two");
printf("Buffer 2 [%p]: %s\n",buffer2,buffer2);
printf("a [%p]: %d\n",&a,a);
printf("Buffer 1 [%p]: %s\n",buffer1,buffer1);
printf("\nCopy Buffer\n\n");
strcpy(buffer2,"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA");
printf("Buffer 2 [%p]: %s\n",buffer2,buffer2);
printf("a [%p]: %d\n",&a,a);
printf("Buffer 1 [%p]: %s\n",buffer1,buffer1);
return 0;
}