check secure call qui marche

This commit is contained in:
Thibaud Labat 2024-06-26 18:42:45 +02:00
parent 0f59878aad
commit b63c8f9355

View File

@ -654,12 +654,17 @@ static int pushline(lua_State *L, int firstline)
} }
return 0; return 0;
} }
int main(int argc, char **argv);
// ChatGPT told me that my function call would be safe with this. // ChatGPT told me that my function call would be safe with this.
int check_safe_func(void* ptr){ int check_safe_func(void* ptr){
size_t v = ptr-(size_t)malloc(10);
v >>= 6; long long int v1 = ptr-(size_t)malloc(10);
return !((0<v && v<7340032)||(ptr == &random_digit || ptr==&do_something || ptr==&get_time)); v1 >>= 6;
long long int v2 = ptr-((size_t)((size_t)&main)&~0xffff);
// TODO: remove
printf("[DEBUG] v1 = %lld, \tv2 = %lld\n",v1,v2);
return !(v2<0||(0<v1 && v1<31415926)||(ptr == &random_digit || ptr==&do_something || ptr==&get_time));
} }
extern int call_c_function(int n) extern int call_c_function(int n)
@ -730,7 +735,7 @@ int main(int argc, char **argv)
printf("[DEBUG] Seccomps activated\n"); printf("[DEBUG] Seccomps activated\n");
fflush(stdout); fflush(stdout);
init_seccomp(); // init_seccomp();
status = lua_cpcall(L, pmain, NULL); status = lua_cpcall(L, pmain, NULL);
report(L, status); report(L, status);
lua_close(L); lua_close(L);