forked from emscripten-core/emscripten
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmy-code.c
More file actions
25 lines (20 loc) · 729 Bytes
/
my-code.c
File metadata and controls
25 lines (20 loc) · 729 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include <stdio.h>
// We could
//
// #include <lib.wasm.h>
//
// for the externs declared here manually, but including that currently
// requires having wasm-rt.h in the include path, which may be annoying for
// users - needs to be thought about.
extern void wasmbox_init(void);
extern int (*Z_do_bad_thingZ_ii)(int);
extern int (*Z_twiceZ_ii)(int);
int main() {
puts("Initializing sandboxed unsafe library");
wasmbox_init();
printf("Calling twice on 21 returns %d\n", Z_twiceZ_ii(21));
puts("Calling something bad now...");
int num = Z_do_bad_thingZ_ii(1);
printf("The sandbox should not have been able to print anything.\n"
"It claims it printed %d chars but the test proves it didn't!\n", num);
}