Skip to content

Commit c25eb19

Browse files
committed
Add support for openssl allocation/deallocation functions.
1 parent 36b2838 commit c25eb19

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

cpp/ql/src/semmle/code/cpp/models/implementations/Allocation.qll

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,18 @@ class MallocAllocationFunction extends AllocationFunction {
8989
or
9090
// kmem_zalloc(size, flags)
9191
name = "kmem_zalloc" and sizeArg = 0
92+
or
93+
// CRYPTO_malloc(size_t num, const char *file, int line)
94+
name = "CRYPTO_malloc" and sizeArg = 0
95+
or
96+
// CRYPTO_zalloc(size_t num, const char *file, int line)
97+
name = "CRYPTO_zalloc" and sizeArg = 0
98+
or
99+
// CRYPTO_secure_malloc(size_t num, const char *file, int line)
100+
name = "CRYPTO_secure_malloc" and sizeArg = 0
101+
or
102+
// CRYPTO_secure_zalloc(size_t num, const char *file, int line)
103+
name = "CRYPTO_secure_zalloc" and sizeArg = 0
92104
)
93105
)
94106
}
@@ -169,6 +181,9 @@ class ReallocAllocationFunction extends AllocationFunction {
169181
or
170182
// CoTaskMemRealloc(ptr, size)
171183
name = "CoTaskMemRealloc" and sizeArg = 1 and reallocArg = 0
184+
or
185+
// CRYPTO_realloc(void *addr, size_t num, const char *file, int line);
186+
name = "CRYPTO_realloc" and sizeArg = 1 and reallocArg = 0
172187
)
173188
)
174189
}

cpp/ql/src/semmle/code/cpp/models/implementations/Deallocation.qll

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ class StandardDeallocationFunction extends DeallocationFunction {
1919
name = "free" and freedArg = 0
2020
or
2121
name = "realloc" and freedArg = 0
22+
or
23+
name = "CRYPTO_free" and freedArg = 0
24+
or
25+
name = "CRYPTO_secure_free" and freedArg = 0
2226
)
2327
or
2428
hasGlobalOrStdName(name) and

0 commit comments

Comments
 (0)