vfs: check userland buffers before reading them.
[haiku.git] / src / tests / system / runtime_loader / test_suite / dlopen_resolve_basic1
blobace9b8774eba291def7931dc3f9c813cb8575d97
1 #!/bin/sh
3 # program
5 # dlopen():
6 # liba.so
8 # Expected: Undefined symbol in liba.so resolve to symbol in program.
11 . ./test_setup
14 # create liba.so
15 cat > liba.c << EOI
16 extern int b();
17 int a() { return b(); }
18 EOI
20 # build
21 compile_lib -o liba.so liba.c
24 # create program
25 cat > program.c << EOI
26 #include <dlfcn.h>
27 #include <stdio.h>
28 #include <stdlib.h>
30 int b() { return 1; }
32 int
33 main()
35 void* liba;
36 int (*a)();
38 liba = dlopen("./liba.so", RTLD_NOW | RTLD_GLOBAL);
39 if (liba == NULL) {
40 /* Fails expectedly. */
41 /* fprintf(stderr, "Error opening liba.so: %s\n", dlerror()); */
42 exit(117);
45 a = (int (*)())dlsym(liba, "a");
46 if (a == NULL) {
47 fprintf(stderr, "Error getting symbol a: %s\n", dlerror());
48 exit(116);
51 return a();
53 EOI
55 # build
56 compile_program_dl -o program program.c
58 # run
59 test_run_ok ./program 1