@@ -19,7 +19,30 @@ import semmle.code.cpp.ir.dataflow.TaintTracking
1919import DataFlow:: PathGraph
2020
2121/**
22- * A taint flow configuration for flow from user input to a buffer write.
22+ * A buffer write into a sensitive expression.
23+ */
24+ class SensitiveBufferWrite extends Expr {
25+ BufferWrite:: BufferWrite write ;
26+
27+ SensitiveBufferWrite ( ) {
28+ this = write and
29+ write .getDest ( ) instanceof SensitiveExpr
30+ }
31+
32+ /**
33+ * Gets a data source of this operation.
34+ */
35+ Expr getASource ( ) { result = write .getASource ( ) }
36+
37+ /**
38+ * Gets the destination buffer of this operation.
39+ */
40+ Expr getDest ( ) { result = write .getDest ( ) }
41+ }
42+
43+ /**
44+ * A taint flow configuration for flow from user input to a buffer write
45+ * into a sensitive expression.
2346 */
2447class ToBufferConfiguration extends TaintTracking:: Configuration {
2548 ToBufferConfiguration ( ) { this = "ToBufferConfiguration" }
@@ -31,12 +54,12 @@ class ToBufferConfiguration extends TaintTracking::Configuration {
3154 }
3255
3356 override predicate isSink ( DataFlow:: Node sink ) {
34- exists ( BufferWrite :: BufferWrite w | w .getASource ( ) = sink .asExpr ( ) )
57+ exists ( SensitiveBufferWrite w | w .getASource ( ) = sink .asExpr ( ) )
3558 }
3659}
3760
3861from
39- ToBufferConfiguration config , BufferWrite :: BufferWrite w , DataFlow:: PathNode sourceNode ,
62+ ToBufferConfiguration config , SensitiveBufferWrite w , DataFlow:: PathNode sourceNode ,
4063 DataFlow:: PathNode sinkNode , FlowSource source , SensitiveExpr dest
4164where
4265 config .hasFlowPath ( sourceNode , sinkNode ) and
0 commit comments