#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;
}
我可以得到分段错误,但无法调用无法访问的函数!?!我知道 Integer 有问题,但我无法利用它.... :( 有没有办法调用它?谢谢