How to create a lightweight C code sandbox?

前端 未结 13 1204
天涯浪人
天涯浪人 2020-11-29 19:43

I\'d like to build a C pre-processor / compiler that allows functions to be collected from local and online sources. ie:

#fetch MP3FileBuilder http://scripts         


        
13条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-29 20:02

    It is impossible to make a static code verifier that can determine that for all possible codes, that a set of code is safe or unsafe, if the language is Turing complete. It is equivalent to the halting problem.

    Of course this point is moot if you have supervisor code running at a lower ring level or being an interpreted language (ie. emulating machine resources).

    The best way to do this is to start the code in another process (ipc is not that bad), and trap system calls like Ptrace in linuxes http://linux.die.net/man/2/ptrace

提交回复
热议问题