I'm working on a project of code safety of online judger. One possible vulnerability is when someone uploads a piece of code like this:
#include "/dev/stdin"
#include "/proc/self/fd/0"
#include <stdio.h>
// Other legitimate code
I'm trying to reproduce it. When compiling it with gcc foo.c
, gcc gets stuck and reads from terminal until EOF (Ctrl-D) as expected. When I clang foo.c
, well, nothing happened. Clang just behaves as if the lines have never existed. Then I tried these codes:
#include "/dev/zero"
#include "/dev/random"
#include "/dev/ram"
Still no luck. Why does Clang ignore all these? How can I make Clang stuck by #include
-ing something?
Make a fifo, and #include it. Note this only appears to stop clang; it doesn’t read from it. This might only work until the clang team see this....