Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e831cb5

Browse files
committed
C++: Add failing tests with 'CComSafeArray'.
1 parent 948be09 commit e831cb5

2 files changed

Lines changed: 163 additions & 0 deletions

File tree

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

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -525,3 +525,80 @@ void test_CComBSTR() {
525525
sink(b.m_str); // $ ir
526526
}
527527
}
528+
529+
template <typename T>
530+
struct CComSafeArray {
531+
CComSafeArray();
532+
CComSafeArray(const SAFEARRAYBOUND& bound);
533+
CComSafeArray(ULONG ulCount, LONG lLBound);
534+
CComSafeArray(const SAFEARRAYBOUND* pBound, UINT uDims);
535+
CComSafeArray(const CComSafeArray& saSrc);
536+
CComSafeArray(const SAFEARRAY& saSrc);
537+
CComSafeArray(const SAFEARRAY* psaSrc);
538+
539+
~CComSafeArray() throw();
540+
541+
HRESULT Add(const SAFEARRAY* psaSrc);
542+
HRESULT Add(ULONG ulCount, const T* pT, BOOL bCopy);
543+
HRESULT Add(const T& t, BOOL bCopy);
544+
HRESULT Attach(const SAFEARRAY* psaSrc);
545+
HRESULT CopyFrom(LPSAFEARRAY* ppArray);
546+
HRESULT CopyTo(LPSAFEARRAY* ppArray);
547+
HRESULT Create(const SAFEARRAYBOUND* pBound, UINT uDims);
548+
HRESULT Create(ULONG ulCount, LONG lLBound);
549+
HRESULT Destroy();
550+
LPSAFEARRAY Detach();
551+
T& GetAt(LONG lIndex) const;
552+
ULONG GetCount(UINT uDim) const;
553+
UINT GetDimensions() const;
554+
LONG GetLowerBound(UINT uDim) const;
555+
LPSAFEARRAY GetSafeArrayPtr() throw();
556+
LONG GetUpperBound(UINT uDim) const;
557+
bool IsSizable() const;
558+
HRESULT MultiDimGetAt(const LONG* alIndex, T& t);
559+
HRESULT MultiDimSetAt(const LONG* alIndex, const T& t);
560+
HRESULT Resize(const SAFEARRAYBOUND* pBound);
561+
HRESULT Resize(ULONG ulCount, LONG lLBound);
562+
HRESULT SetAt(LONG lIndex, const T& t, BOOL bCopy);
563+
operator LPSAFEARRAY() const;
564+
T& operator[](long lindex) const;
565+
T& operator[](int nindex) const;
566+
567+
LPSAFEARRAY m_psa;
568+
};
569+
570+
void test_CComSafeArray() {
571+
LPSAFEARRAY safe = getSafeArray();
572+
sink(safe->pvData); // $ ir
573+
{
574+
CComSafeArray<int> c(safe);
575+
sink(c[0]); // $ MISSING: ir
576+
sink(c.GetAt(0)); // $ MISSING: ir
577+
sink(c.GetSafeArrayPtr()->pvData); // $ MISSING: ir
578+
sink(c.m_psa->pvData); // $ MISSING: ir
579+
}
580+
{
581+
CComSafeArray<int> c;
582+
sink(c[0]);
583+
sink(c.GetAt(0));
584+
sink(c.GetSafeArrayPtr()->pvData);
585+
c.Add(safe);
586+
sink(c[0]); // $ MISSING: ir
587+
sink(c.GetAt(0)); // $ MISSING: ir
588+
sink(c.GetSafeArrayPtr()->pvData); // $ MISSING: ir
589+
sink(static_cast<LPSAFEARRAY>(c)->pvData); // $ MISSING: ir
590+
}
591+
{
592+
CComSafeArray<int> c;
593+
c.Add(source<int>(), true);
594+
sink(c[0]); // $ MISSING: ir
595+
sink(c.GetAt(0)); // $ MISSING: ir
596+
sink(c.GetSafeArrayPtr()->pvData); // $ MISSING: ir
597+
}
598+
{
599+
CComSafeArray<int> c;
600+
c.SetAt(0, source<int>(), true);
601+
sink(c[0]); // $ MISSING: ir
602+
sink(c[0L]); // $ MISSING: ir
603+
}
604+
}

cpp/ql/test/library-tests/dataflow/taint-tests/localTaint.expected

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -636,6 +636,92 @@ WARNING: module 'TaintTracking' has been deprecated and may be removed in future
636636
| atl.cpp:524:16:524:21 | call to CComBSTR | atl.cpp:525:10:525:10 | b | |
637637
| atl.cpp:524:16:524:21 | call to CComBSTR | atl.cpp:526:3:526:3 | b | |
638638
| atl.cpp:525:10:525:10 | b [post update] | atl.cpp:526:3:526:3 | b | |
639+
| atl.cpp:569:22:569:33 | call to getSafeArray | atl.cpp:570:8:570:11 | safe | |
640+
| atl.cpp:569:22:569:33 | call to getSafeArray | atl.cpp:572:24:572:27 | safe | |
641+
| atl.cpp:569:22:569:33 | call to getSafeArray | atl.cpp:582:11:582:14 | safe | |
642+
| atl.cpp:570:8:570:11 | safe [post update] | atl.cpp:572:24:572:27 | safe | |
643+
| atl.cpp:570:8:570:11 | safe [post update] | atl.cpp:582:11:582:14 | safe | |
644+
| atl.cpp:572:24:572:27 | safe | atl.cpp:572:24:572:28 | call to CComSafeArray | TAINT |
645+
| atl.cpp:572:24:572:28 | call to CComSafeArray | atl.cpp:573:8:573:8 | c | |
646+
| atl.cpp:572:24:572:28 | call to CComSafeArray | atl.cpp:574:8:574:8 | c | |
647+
| atl.cpp:572:24:572:28 | call to CComSafeArray | atl.cpp:575:8:575:8 | c | |
648+
| atl.cpp:572:24:572:28 | call to CComSafeArray | atl.cpp:576:3:576:3 | c | |
649+
| atl.cpp:573:8:573:8 | ref arg c | atl.cpp:574:8:574:8 | c | |
650+
| atl.cpp:573:8:573:8 | ref arg c | atl.cpp:575:8:575:8 | c | |
651+
| atl.cpp:573:8:573:8 | ref arg c | atl.cpp:576:3:576:3 | c | |
652+
| atl.cpp:574:8:574:8 | ref arg c | atl.cpp:575:8:575:8 | c | |
653+
| atl.cpp:574:8:574:8 | ref arg c | atl.cpp:576:3:576:3 | c | |
654+
| atl.cpp:575:8:575:8 | ref arg c | atl.cpp:576:3:576:3 | c | |
655+
| atl.cpp:578:24:578:24 | call to CComSafeArray | atl.cpp:579:10:579:10 | c | |
656+
| atl.cpp:578:24:578:24 | call to CComSafeArray | atl.cpp:580:10:580:10 | c | |
657+
| atl.cpp:578:24:578:24 | call to CComSafeArray | atl.cpp:581:10:581:10 | c | |
658+
| atl.cpp:578:24:578:24 | call to CComSafeArray | atl.cpp:582:5:582:5 | c | |
659+
| atl.cpp:578:24:578:24 | call to CComSafeArray | atl.cpp:583:10:583:10 | c | |
660+
| atl.cpp:578:24:578:24 | call to CComSafeArray | atl.cpp:584:10:584:10 | c | |
661+
| atl.cpp:578:24:578:24 | call to CComSafeArray | atl.cpp:585:10:585:10 | c | |
662+
| atl.cpp:578:24:578:24 | call to CComSafeArray | atl.cpp:586:35:586:35 | c | |
663+
| atl.cpp:578:24:578:24 | call to CComSafeArray | atl.cpp:587:3:587:3 | c | |
664+
| atl.cpp:579:10:579:10 | ref arg c | atl.cpp:580:10:580:10 | c | |
665+
| atl.cpp:579:10:579:10 | ref arg c | atl.cpp:581:10:581:10 | c | |
666+
| atl.cpp:579:10:579:10 | ref arg c | atl.cpp:582:5:582:5 | c | |
667+
| atl.cpp:579:10:579:10 | ref arg c | atl.cpp:583:10:583:10 | c | |
668+
| atl.cpp:579:10:579:10 | ref arg c | atl.cpp:584:10:584:10 | c | |
669+
| atl.cpp:579:10:579:10 | ref arg c | atl.cpp:585:10:585:10 | c | |
670+
| atl.cpp:579:10:579:10 | ref arg c | atl.cpp:586:35:586:35 | c | |
671+
| atl.cpp:579:10:579:10 | ref arg c | atl.cpp:587:3:587:3 | c | |
672+
| atl.cpp:580:10:580:10 | ref arg c | atl.cpp:581:10:581:10 | c | |
673+
| atl.cpp:580:10:580:10 | ref arg c | atl.cpp:582:5:582:5 | c | |
674+
| atl.cpp:580:10:580:10 | ref arg c | atl.cpp:583:10:583:10 | c | |
675+
| atl.cpp:580:10:580:10 | ref arg c | atl.cpp:584:10:584:10 | c | |
676+
| atl.cpp:580:10:580:10 | ref arg c | atl.cpp:585:10:585:10 | c | |
677+
| atl.cpp:580:10:580:10 | ref arg c | atl.cpp:586:35:586:35 | c | |
678+
| atl.cpp:580:10:580:10 | ref arg c | atl.cpp:587:3:587:3 | c | |
679+
| atl.cpp:581:10:581:10 | ref arg c | atl.cpp:582:5:582:5 | c | |
680+
| atl.cpp:581:10:581:10 | ref arg c | atl.cpp:583:10:583:10 | c | |
681+
| atl.cpp:581:10:581:10 | ref arg c | atl.cpp:584:10:584:10 | c | |
682+
| atl.cpp:581:10:581:10 | ref arg c | atl.cpp:585:10:585:10 | c | |
683+
| atl.cpp:581:10:581:10 | ref arg c | atl.cpp:586:35:586:35 | c | |
684+
| atl.cpp:581:10:581:10 | ref arg c | atl.cpp:587:3:587:3 | c | |
685+
| atl.cpp:582:5:582:5 | ref arg c | atl.cpp:583:10:583:10 | c | |
686+
| atl.cpp:582:5:582:5 | ref arg c | atl.cpp:584:10:584:10 | c | |
687+
| atl.cpp:582:5:582:5 | ref arg c | atl.cpp:585:10:585:10 | c | |
688+
| atl.cpp:582:5:582:5 | ref arg c | atl.cpp:586:35:586:35 | c | |
689+
| atl.cpp:582:5:582:5 | ref arg c | atl.cpp:587:3:587:3 | c | |
690+
| atl.cpp:583:10:583:10 | ref arg c | atl.cpp:584:10:584:10 | c | |
691+
| atl.cpp:583:10:583:10 | ref arg c | atl.cpp:585:10:585:10 | c | |
692+
| atl.cpp:583:10:583:10 | ref arg c | atl.cpp:586:35:586:35 | c | |
693+
| atl.cpp:583:10:583:10 | ref arg c | atl.cpp:587:3:587:3 | c | |
694+
| atl.cpp:584:10:584:10 | ref arg c | atl.cpp:585:10:585:10 | c | |
695+
| atl.cpp:584:10:584:10 | ref arg c | atl.cpp:586:35:586:35 | c | |
696+
| atl.cpp:584:10:584:10 | ref arg c | atl.cpp:587:3:587:3 | c | |
697+
| atl.cpp:585:10:585:10 | ref arg c | atl.cpp:586:35:586:35 | c | |
698+
| atl.cpp:585:10:585:10 | ref arg c | atl.cpp:587:3:587:3 | c | |
699+
| atl.cpp:586:35:586:35 | ref arg c | atl.cpp:587:3:587:3 | c | |
700+
| atl.cpp:589:24:589:24 | call to CComSafeArray | atl.cpp:590:5:590:5 | c | |
701+
| atl.cpp:589:24:589:24 | call to CComSafeArray | atl.cpp:591:10:591:10 | c | |
702+
| atl.cpp:589:24:589:24 | call to CComSafeArray | atl.cpp:592:10:592:10 | c | |
703+
| atl.cpp:589:24:589:24 | call to CComSafeArray | atl.cpp:593:10:593:10 | c | |
704+
| atl.cpp:589:24:589:24 | call to CComSafeArray | atl.cpp:594:3:594:3 | c | |
705+
| atl.cpp:590:5:590:5 | ref arg c | atl.cpp:591:10:591:10 | c | |
706+
| atl.cpp:590:5:590:5 | ref arg c | atl.cpp:592:10:592:10 | c | |
707+
| atl.cpp:590:5:590:5 | ref arg c | atl.cpp:593:10:593:10 | c | |
708+
| atl.cpp:590:5:590:5 | ref arg c | atl.cpp:594:3:594:3 | c | |
709+
| atl.cpp:591:10:591:10 | ref arg c | atl.cpp:592:10:592:10 | c | |
710+
| atl.cpp:591:10:591:10 | ref arg c | atl.cpp:593:10:593:10 | c | |
711+
| atl.cpp:591:10:591:10 | ref arg c | atl.cpp:594:3:594:3 | c | |
712+
| atl.cpp:592:10:592:10 | ref arg c | atl.cpp:593:10:593:10 | c | |
713+
| atl.cpp:592:10:592:10 | ref arg c | atl.cpp:594:3:594:3 | c | |
714+
| atl.cpp:593:10:593:10 | ref arg c | atl.cpp:594:3:594:3 | c | |
715+
| atl.cpp:596:24:596:24 | call to CComSafeArray | atl.cpp:597:5:597:5 | c | |
716+
| atl.cpp:596:24:596:24 | call to CComSafeArray | atl.cpp:598:10:598:10 | c | |
717+
| atl.cpp:596:24:596:24 | call to CComSafeArray | atl.cpp:599:10:599:10 | c | |
718+
| atl.cpp:596:24:596:24 | call to CComSafeArray | atl.cpp:600:3:600:3 | c | |
719+
| atl.cpp:597:5:597:5 | ref arg c | atl.cpp:598:10:598:10 | c | |
720+
| atl.cpp:597:5:597:5 | ref arg c | atl.cpp:599:10:599:10 | c | |
721+
| atl.cpp:597:5:597:5 | ref arg c | atl.cpp:600:3:600:3 | c | |
722+
| atl.cpp:598:10:598:10 | ref arg c | atl.cpp:599:10:599:10 | c | |
723+
| atl.cpp:598:10:598:10 | ref arg c | atl.cpp:600:3:600:3 | c | |
724+
| atl.cpp:599:10:599:10 | ref arg c | atl.cpp:600:3:600:3 | c | |
639725
| bsd.cpp:17:11:17:16 | call to source | bsd.cpp:20:18:20:18 | s | |
640726
| bsd.cpp:18:12:18:15 | addr | bsd.cpp:20:22:20:25 | addr | |
641727
| bsd.cpp:18:12:18:15 | addr | bsd.cpp:23:8:23:11 | addr | |

0 commit comments

Comments
 (0)