-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdw-wrap-glibc.h
27 lines (21 loc) · 1.14 KB
/
dw-wrap-glibc.h
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
26
27
#ifndef DW_WRAP_GLIBC_H
#define DW_WRAP_GLIBC_H
size_t dw_strlen(const char *s);
// Each library function wrapper will check the pointers received as argument,
// and untaint them before calling the real function.
//
// Each wrapper starts with dw_sin() to indicate that we are within wrappers.
// We first insure that pointers to wrapped symbols are initialized.
// It would be tricky to put the wrapped symbols initialization in
// a "constructor", because some of those wrappers may get called by functions in other
// libraries, before the constructor for this module gets called.
// Thereafter, pointers received as arguments are untainted, and tainting
// pointers generated by nested malloc calls is deactivated. Tainted pointers should not
// be encountered while within wrappers, and calls to wrapped functions should be avoided.
//
// Upon exit, sout() restores the state of pointer tainting.
extern int dw_init_stubs;
void dw_init_syscall_stubs();
#define dw_sin() bool sin_save = dw_protect_active; dw_protect_active = false; if(!dw_init_stubs) dw_init_syscall_stubs()
#define dw_sout() dw_protect_active = sin_save
#endif /* DW_WRAP_GLIBC_H */