/* * This program demonstrates a leak in freebsd exec(), which [erroneously] * allows ELF program to get as much memory as it wishes, ignoring *rlimit * settings, while [correctly] denying any non-ELF program to exceed *rlimit * settings on exec(). * How to use: * gcc -elf -o m_elf m.c # compat 3 probably required for fbsd4 * gcc -aout -o m_aout m.c * /usr/bin/limits -d 1 ./m_aout * /usr/bin/limits -d 1 ./m_elf * you'll see the difference. */ #include #include #include char a[ 10000000 ] ; int main( int ac, char **av ) { memset( a, 1, sizeof(a) ) ; puts( "sleeping" ) ; sleep( 100 ) ; return 0 ; }