C++: Can function pointers be traced back to the original function before compilation without looking at the function name? -
i want set server on students can upload , run code course. however, don't want them access various functions, system(), allow bad access server. can search pre-processor output explicit function call, if user makes function pointer this:
int (*syst)(const char*) = system; syst("rm *");
i'm still open threat. however, can't search string "system", example, since it's otherwise valid name - if student didn't include cstdlib, use name variable name. since beginning programming course, having blacklist of variable names ten miles long bad idea.
is there way define functions other name , allow me search other designation before compiling code?
by far easiest solution compile code - that's pretty harmless - , @ actual library imports. users may have defined own system
, wouldn't cause system
imported glibc
.
the main reason can't @ raw source code because #define
allows malicious users hide blacklisted symbol names. there plenty of other possibilities that, including
auto hidden = &sys\ tem;
so need processing of source, , it's easiest process whole source.
Comments
Post a Comment