#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;
}
セグメンテーション フォールトを取得できますが、到達不能関数を呼び出すことはできません!?! 整数に問題があることは知っていますが、それを悪用することはできません.... :(それを呼び出す方法はありますか? Thx