Skip to content

Commit c61395b

Browse files
committed
C++: Add implicit read of the 'm_strPath' member.
1 parent 3543619 commit c61395b

3 files changed

Lines changed: 26 additions & 9 deletions

File tree

cpp/ql/lib/semmle/code/cpp/models/Models.qll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,4 @@ private import implementations.ZMQ
5252
private import implementations.Win32CommandExecution
5353
private import implementations.CA2AEX
5454
private import implementations.CComBSTR
55+
private import implementations.CPathT
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
private import cpp
2+
private import semmle.code.cpp.ir.dataflow.FlowSteps
3+
private import semmle.code.cpp.dataflow.new.DataFlow
4+
5+
/** The `CPathT` class from the Microsoft "Active Template Library". */
6+
class CPathT extends Class {
7+
CPathT() { this.hasGlobalName("CPathT") }
8+
}
9+
10+
private class MStrPath extends Field {
11+
MStrPath() { this.getDeclaringType() instanceof CPathT and this.hasName("m_strPath") }
12+
}
13+
14+
private class MStrPathTaintInheritingContent extends TaintInheritingContent, DataFlow::FieldContent {
15+
MStrPathTaintInheritingContent() { this.getField() instanceof MStrPath }
16+
}

cpp/ql/test/library-tests/dataflow/taint-tests/atl.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -664,45 +664,45 @@ void test_CPathT() {
664664
char* x = indirect_source<char>();
665665
CPath p(x);
666666
sink(static_cast<char*>(p)); // $ MISSING: ir
667-
sink(p.m_strPath); // $ MISSING: ir
667+
sink(p.m_strPath); // $ ir
668668

669669
CPath p2(p);
670-
sink(p2.m_strPath); // $ MISSING: ir
670+
sink(p2.m_strPath); // $ ir
671671

672672
{
673673
CPath p;
674674
p.AddExtension(x);
675-
sink(p.m_strPath); // $ MISSING: ir
675+
sink(p.m_strPath); // $ ir
676676
}
677677
{
678678
CPath p;
679679
p.Append(x);
680-
sink(p.m_strPath); // $ MISSING: ir
680+
sink(p.m_strPath); // $ ir
681681

682682
CPath p2;
683683
p2 += p;
684-
sink(p.m_strPath); // $ MISSING: ir
684+
sink(p.m_strPath); // $ ir
685685

686686
CPath p3;
687687
p3 += x;
688-
sink(p.m_strPath); // $ MISSING: ir
688+
sink(p.m_strPath); // $ ir
689689
}
690690

691691
{
692692
CPath p;
693693
p.Combine(x, nullptr);
694-
sink(p.m_strPath); // $ MISSING: ir
694+
sink(p.m_strPath); // $ ir
695695
}
696696
{
697697
CPath p;
698698
p.Combine(nullptr, x);
699-
sink(p.m_strPath); // $ MISSING: ir
699+
sink(p.m_strPath); // $ ir
700700
}
701701

702702
{
703703
CPath p;
704704
auto p2 = p.CommonPrefix(x);
705-
sink(p2.m_strPath); // $ MISSING: ir
705+
sink(p2.m_strPath); // $ ir
706706
sink(p2.GetExtension()); // $ ir
707707
}
708708
}

0 commit comments

Comments
 (0)