#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <string.h>
#define MAX 3
#define ARG "cat .passwd"
integer main( integer argc, char ** argv )
{
char * names[] = {"strlen", "atoi", "printf", "puts"};
void (*reachable_functions[])( char * ) = {strlen, atoi, printf, puts};
void (*unreachable_functions[])( char * ) = {system};
integer i, index = 0;
for( i=1; i<argc; i++ )
{
index += strlen(argv[i]);
}
if( index <= MAX )
{
(reachable_functions[MAX-1])( "Calling ");
(reachable_functions[MAX-1])( names[index] );
(reachable_functions[MAX-1])( ".\n" );
(reachable_functions[index])( ARG );
}
else
{
(reachable_functions[MAX])( "Out of bounds !\n" );
}
return 0;
}
I can get a Segmentation Fault but impossible to call the unreachable function !?! I know there is a problem with the Integer but i can't exploit it.... :( Is there a way to call it ? Thx