-
Notifications
You must be signed in to change notification settings - Fork 509
Expand file tree
/
Copy pathsafe_context.cpp
More file actions
35 lines (32 loc) · 1.18 KB
/
safe_context.cpp
File metadata and controls
35 lines (32 loc) · 1.18 KB
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
28
29
30
31
32
33
34
35
#include "api/safe_context.h"
// ============================================================================
// Safe wrapper functions for global pointers
// ============================================================================
// These functions centralize null checks for taint_engine_context and
// initializer to prevent segmentation faults when called before
// initialize_native_state(). All aspect functions should use these wrappers
// instead of accessing the globals directly.
TaintedObjectMapTypePtr
safe_get_tainted_object_map(PyObject* tainted_object)
{
if (!taint_engine_context) {
return nullptr;
}
return taint_engine_context->get_tainted_object_map(tainted_object);
}
TaintedObjectMapTypePtr
safe_get_tainted_object_map_from_list_of_pyobjects(const std::vector<PyObject*>& objects)
{
if (!taint_engine_context) {
return nullptr;
}
return taint_engine_context->get_tainted_object_map_from_list_of_pyobjects(objects);
}
TaintedObjectMapTypePtr
safe_get_tainted_object_map_by_ctx_id(size_t ctx_id)
{
if (!taint_engine_context) {
return nullptr;
}
return taint_engine_context->get_tainted_object_map_by_ctx_id(ctx_id);
}