Skip to content

Commit c537f5a

Browse files
committed
chcekpoint
1 parent 8a7f9e3 commit c537f5a

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# CON30-C: Clean up thread-specific storage
2+
3+
This query implements the CERT-C rule CON30-C:
4+
5+
> Clean up thread-specific storage
6+
7+
8+
## CERT
9+
10+
** REPLACE THIS BY RUNNING THE SCRIPT `scripts/help/cert-help-extraction.py` **
11+
12+
## Implementation notes
13+
14+
This query does not attempt to ensure that the deallocation function in fact deallocates memory and instead assumes the contract is valid.
15+
16+
## References
17+
18+
* CERT-C: [CON30-C: Clean up thread-specific storage](https://wiki.sei.cmu.edu/confluence/display/c)
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/**
2+
* @id c/cert/clean-up-thread-specific-storage
3+
* @name CON30-C: Clean up thread-specific storage
4+
* @description Failing to clean up thread-specific resources can lead to unpredictable program
5+
* behavior.
6+
* @kind problem
7+
* @precision medium
8+
* @problem.severity error
9+
* @tags external/cert/id/con30-c
10+
* correctness
11+
* concurrency
12+
* external/cert/obligation/rule
13+
*/
14+
15+
import cpp
16+
import codingstandards.c.cert
17+
18+
// there are two safe patterns.
19+
// 1) They call free(tss_get(key))
20+
// 2) They call tss_create(key, destructor) -- we don't make an attempt to
21+
// understand what the function is. They must also call tss_delete(key)
22+
// THAT MEANS there is dataflow from tss_create -> tss_delete
23+
// OR there is dataflow from tss_create -> tss_delete
24+
// we just make sure in one arg version it's wrapped in a call to free.
25+
// That IS there is taint from tss_create -> free();
26+
27+
from Function f
28+
where
29+
not isExcluded(f, Concurrency4Package::cleanUpThreadSpecificStorageQuery())
30+
and nm
31+
select mi.getExpr()

0 commit comments

Comments
 (0)