File tree Expand file tree Collapse file tree 2 files changed +49
-0
lines changed
Filter options
Expand file tree Collapse file tree 2 files changed +49
-0
lines changed
Original file line number Diff line number Diff line change
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 )
Original file line number Diff line number Diff line change
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 ( )
You can’t perform that action at this time.
0 commit comments