Odd .....

Ben Duncan bns
Fri Jun 16 08:03:57 PDT 2006


In one of my test C programs, malloc'd a 2048 byte memory page.
I decided to see if I could segfault it (testing a thery)
and it did NOT segfault ... what Am I doing wrong, or is this
just how things works ... And is there a way to test for
any of these buffer overruns ?

ie:

char *buffer_ptr ;
char TEST_STRING [ ] = "TEST STRING" ;

buffer_ptr = malloc (2048) ;
... do some stuff putting things in the buffer ...
buffer_ptr = buffer_ptr + 2096 ;
memcpy ( buffer_ptr, TEST_STRING, sizeof (TEST_STRING ) ) ;

And I got no segfault doing this ...


-- 
Ben Duncan   - Business Network Solutions, Inc. 336 Elton Road  Jackson MS, 39212
"Never attribute to malice, that which can be adequately explained by stupidity"
        - Hanlon's Razor




More information about the Linux-users mailing list