Linux-2.4.22 memory overwriting

From: Julien Rebetez
Date: Sun Feb 01 2004 - 07:15:07 EST


Hi !
I've writen the following program :


#include <stdio.h>

int main ()
{
int p[4];
p[0]=1;
p[1]=2;
p[2]=3;
p[3]=4;
p[4]=5;

printf ("%i, %i, %i, %i, %i\n", p[0], p[1], p[2], p[3],
p[4]);
return 0;
}

I compile it with :

gcc -o test test.c -Wall

and when i launch it, the output is :

julien:$> ./test
1, 2, 3, 4, 5

Should I not get a SIGSEV from the system ? Isn't it dangerous to allow the user to put 5 elements in a 4 elements tab?

(tested on Linux 2.4.22 on a i686)

Thanks

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/