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

Skip to content

Commit 1cd426e

Browse files
committed
C++: Add failing tests with 'CAtlArray'.
1 parent 4f2cd81 commit 1cd426e

2 files changed

Lines changed: 228 additions & 0 deletions

File tree

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

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,3 +166,86 @@ void test_CA2WEX() {
166166
sink(a.m_psz); // $ ir
167167
}
168168
}
169+
170+
template<typename T>
171+
struct CElementTraitsBase {
172+
typedef const T& INARGTYPE;
173+
typedef T& OUTARGTYPE;
174+
175+
static void CopyElements(T* pDest, const T* pSrc, size_t nElements);
176+
static void RelocateElements(T* pDest, T* pSrc, size_t nElements);
177+
};
178+
179+
template <typename T>
180+
struct CDefaultElementTraits : public CElementTraitsBase<T> {};
181+
182+
template<typename T>
183+
struct CElementTraits : public CDefaultElementTraits<T> {};
184+
185+
template<typename E, class ETraits = CElementTraits<E>>
186+
struct CAtlArray {
187+
using INARGTYPE = typename ETraits::INARGTYPE;
188+
using OUTARGTYPE = typename ETraits::OUTARGTYPE;
189+
190+
CAtlArray() throw();
191+
~CAtlArray() throw();
192+
193+
size_t Add(INARGTYPE element);
194+
size_t Add();
195+
size_t Append(const CAtlArray<E, ETraits>& aSrc);
196+
void Copy(const CAtlArray<E, ETraits>& aSrc);
197+
const E& GetAt(size_t iElement) const throw();
198+
E& GetAt(size_t iElement) throw();
199+
size_t GetCount() const throw();
200+
E* GetData() throw();
201+
const E* GetData() const throw();
202+
void InsertArrayAt(size_t iStart, const CAtlArray<E, ETraits>* paNew);
203+
void InsertAt(size_t iElement, INARGTYPE element, size_t nCount);
204+
bool IsEmpty() const throw();
205+
void RemoveAll() throw();
206+
void RemoveAt(size_t iElement, size_t nCount);
207+
void SetAt(size_t iElement, INARGTYPE element);
208+
void SetAtGrow(size_t iElement, INARGTYPE element);
209+
bool SetCount(size_t nNewSize, int nGrowBy);
210+
E& operator[](size_t ielement) throw();
211+
const E& operator[](size_t ielement) const throw();
212+
};
213+
214+
void test_CAtlArray() {
215+
int x = source<int>();
216+
217+
{
218+
CAtlArray<int> a;
219+
a.Add(x);
220+
sink(a[0]); // $ MISSING: ir
221+
a.Add(0);
222+
sink(a[0]); // $ MISSING: ir
223+
224+
CAtlArray<int> a2;
225+
sink(a2[0]);
226+
a2.Append(a);
227+
sink(a2[0]); // $ MISSING: ir
228+
229+
CAtlArray<int> a3;
230+
sink(a3[0]);
231+
a3.Copy(a2);
232+
sink(a3[0]); // $ MISSING: ir
233+
234+
sink(a3.GetAt(0)); // $ MISSING: ir
235+
sink(*a3.GetData()); // $ MISSING: ir
236+
237+
CAtlArray<int> a4;
238+
sink(a4.GetAt(0));
239+
a4.InsertArrayAt(0, &a3);
240+
sink(a4.GetAt(0)); // $ MISSING: ir
241+
}
242+
{
243+
CAtlArray<int> a5;
244+
a5.InsertAt(0, source<int>(), 1);
245+
sink(a5[0]); // $ MISSING: ir
246+
247+
CAtlArray<int> a6;
248+
a6.SetAtGrow(0, source<int>());
249+
sink(a6[0]); // $ MISSING: ir
250+
}
251+
}

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

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,151 @@ WARNING: module 'TaintTracking' has been deprecated and may be removed in future
147147
| atl.cpp:82:17:82:43 | call to indirect_source | atl.cpp:83:21:83:21 | y | |
148148
| atl.cpp:83:21:83:21 | y | atl.cpp:83:21:83:22 | call to _U_STRINGorID | TAINT |
149149
| atl.cpp:83:21:83:22 | call to _U_STRINGorID | atl.cpp:84:10:84:10 | u | |
150+
| atl.cpp:103:15:103:35 | call to indirect_source | atl.cpp:104:19:104:19 | x | |
151+
| atl.cpp:104:19:104:19 | x | atl.cpp:104:19:104:20 | call to CA2AEX | TAINT |
152+
| atl.cpp:104:19:104:20 | call to CA2AEX | atl.cpp:105:29:105:29 | a | |
153+
| atl.cpp:104:19:104:20 | call to CA2AEX | atl.cpp:106:10:106:10 | a | |
154+
| atl.cpp:104:19:104:20 | call to CA2AEX | atl.cpp:107:10:107:10 | a | |
155+
| atl.cpp:104:19:104:20 | call to CA2AEX | atl.cpp:108:3:108:3 | a | |
156+
| atl.cpp:105:29:105:29 | ref arg a | atl.cpp:106:10:106:10 | a | |
157+
| atl.cpp:105:29:105:29 | ref arg a | atl.cpp:107:10:107:10 | a | |
158+
| atl.cpp:105:29:105:29 | ref arg a | atl.cpp:108:3:108:3 | a | |
159+
| atl.cpp:106:10:106:10 | a [post update] | atl.cpp:107:10:107:10 | a | |
160+
| atl.cpp:106:10:106:10 | a [post update] | atl.cpp:108:3:108:3 | a | |
161+
| atl.cpp:107:10:107:10 | a [post update] | atl.cpp:108:3:108:3 | a | |
162+
| atl.cpp:111:15:111:35 | call to indirect_source | atl.cpp:112:19:112:19 | x | |
163+
| atl.cpp:112:19:112:23 | call to CA2AEX | atl.cpp:113:29:113:29 | a | |
164+
| atl.cpp:112:19:112:23 | call to CA2AEX | atl.cpp:114:10:114:10 | a | |
165+
| atl.cpp:112:19:112:23 | call to CA2AEX | atl.cpp:115:10:115:10 | a | |
166+
| atl.cpp:112:19:112:23 | call to CA2AEX | atl.cpp:116:3:116:3 | a | |
167+
| atl.cpp:113:29:113:29 | ref arg a | atl.cpp:114:10:114:10 | a | |
168+
| atl.cpp:113:29:113:29 | ref arg a | atl.cpp:115:10:115:10 | a | |
169+
| atl.cpp:113:29:113:29 | ref arg a | atl.cpp:116:3:116:3 | a | |
170+
| atl.cpp:114:10:114:10 | a [post update] | atl.cpp:115:10:115:10 | a | |
171+
| atl.cpp:114:10:114:10 | a [post update] | atl.cpp:116:3:116:3 | a | |
172+
| atl.cpp:115:10:115:10 | a [post update] | atl.cpp:116:3:116:3 | a | |
173+
| atl.cpp:129:14:129:34 | call to indirect_source | atl.cpp:131:20:131:20 | x | |
174+
| atl.cpp:129:14:129:34 | call to indirect_source | atl.cpp:137:20:137:20 | x | |
175+
| atl.cpp:131:20:131:20 | x | atl.cpp:131:20:131:21 | call to CA2CAEX | TAINT |
176+
| atl.cpp:131:20:131:21 | call to CA2CAEX | atl.cpp:132:30:132:30 | a | |
177+
| atl.cpp:131:20:131:21 | call to CA2CAEX | atl.cpp:133:10:133:10 | a | |
178+
| atl.cpp:131:20:131:21 | call to CA2CAEX | atl.cpp:134:10:134:10 | a | |
179+
| atl.cpp:131:20:131:21 | call to CA2CAEX | atl.cpp:135:3:135:3 | a | |
180+
| atl.cpp:137:20:137:24 | call to CA2CAEX | atl.cpp:138:30:138:30 | a | |
181+
| atl.cpp:137:20:137:24 | call to CA2CAEX | atl.cpp:139:10:139:10 | a | |
182+
| atl.cpp:137:20:137:24 | call to CA2CAEX | atl.cpp:140:10:140:10 | a | |
183+
| atl.cpp:137:20:137:24 | call to CA2CAEX | atl.cpp:141:3:141:3 | a | |
184+
| atl.cpp:155:14:155:34 | call to indirect_source | atl.cpp:157:19:157:19 | x | |
185+
| atl.cpp:155:14:155:34 | call to indirect_source | atl.cpp:163:19:163:19 | x | |
186+
| atl.cpp:157:19:157:19 | x | atl.cpp:157:19:157:20 | call to CA2WEX | TAINT |
187+
| atl.cpp:157:19:157:20 | call to CA2WEX | atl.cpp:158:30:158:30 | a | |
188+
| atl.cpp:157:19:157:20 | call to CA2WEX | atl.cpp:159:10:159:10 | a | |
189+
| atl.cpp:157:19:157:20 | call to CA2WEX | atl.cpp:160:10:160:10 | a | |
190+
| atl.cpp:157:19:157:20 | call to CA2WEX | atl.cpp:161:3:161:3 | a | |
191+
| atl.cpp:158:30:158:30 | ref arg a | atl.cpp:159:10:159:10 | a | |
192+
| atl.cpp:158:30:158:30 | ref arg a | atl.cpp:160:10:160:10 | a | |
193+
| atl.cpp:158:30:158:30 | ref arg a | atl.cpp:161:3:161:3 | a | |
194+
| atl.cpp:159:10:159:10 | a [post update] | atl.cpp:160:10:160:10 | a | |
195+
| atl.cpp:159:10:159:10 | a [post update] | atl.cpp:161:3:161:3 | a | |
196+
| atl.cpp:159:12:159:16 | ref arg m_psz | atl.cpp:160:12:160:16 | m_psz | |
197+
| atl.cpp:160:10:160:10 | a [post update] | atl.cpp:161:3:161:3 | a | |
198+
| atl.cpp:163:19:163:23 | call to CA2WEX | atl.cpp:164:30:164:30 | a | |
199+
| atl.cpp:163:19:163:23 | call to CA2WEX | atl.cpp:165:10:165:10 | a | |
200+
| atl.cpp:163:19:163:23 | call to CA2WEX | atl.cpp:166:10:166:10 | a | |
201+
| atl.cpp:163:19:163:23 | call to CA2WEX | atl.cpp:167:3:167:3 | a | |
202+
| atl.cpp:164:30:164:30 | ref arg a | atl.cpp:165:10:165:10 | a | |
203+
| atl.cpp:164:30:164:30 | ref arg a | atl.cpp:166:10:166:10 | a | |
204+
| atl.cpp:164:30:164:30 | ref arg a | atl.cpp:167:3:167:3 | a | |
205+
| atl.cpp:165:10:165:10 | a [post update] | atl.cpp:166:10:166:10 | a | |
206+
| atl.cpp:165:10:165:10 | a [post update] | atl.cpp:167:3:167:3 | a | |
207+
| atl.cpp:165:12:165:16 | ref arg m_psz | atl.cpp:166:12:166:16 | m_psz | |
208+
| atl.cpp:166:10:166:10 | a [post update] | atl.cpp:167:3:167:3 | a | |
209+
| atl.cpp:215:11:215:21 | call to source | atl.cpp:219:11:219:11 | x | |
210+
| atl.cpp:218:20:218:20 | call to CAtlArray | atl.cpp:219:5:219:5 | a | |
211+
| atl.cpp:218:20:218:20 | call to CAtlArray | atl.cpp:220:10:220:10 | a | |
212+
| atl.cpp:218:20:218:20 | call to CAtlArray | atl.cpp:221:5:221:5 | a | |
213+
| atl.cpp:218:20:218:20 | call to CAtlArray | atl.cpp:222:10:222:10 | a | |
214+
| atl.cpp:218:20:218:20 | call to CAtlArray | atl.cpp:226:15:226:15 | a | |
215+
| atl.cpp:218:20:218:20 | call to CAtlArray | atl.cpp:241:3:241:3 | a | |
216+
| atl.cpp:219:5:219:5 | ref arg a | atl.cpp:220:10:220:10 | a | |
217+
| atl.cpp:219:5:219:5 | ref arg a | atl.cpp:221:5:221:5 | a | |
218+
| atl.cpp:219:5:219:5 | ref arg a | atl.cpp:222:10:222:10 | a | |
219+
| atl.cpp:219:5:219:5 | ref arg a | atl.cpp:226:15:226:15 | a | |
220+
| atl.cpp:219:5:219:5 | ref arg a | atl.cpp:241:3:241:3 | a | |
221+
| atl.cpp:220:10:220:10 | ref arg a | atl.cpp:221:5:221:5 | a | |
222+
| atl.cpp:220:10:220:10 | ref arg a | atl.cpp:222:10:222:10 | a | |
223+
| atl.cpp:220:10:220:10 | ref arg a | atl.cpp:226:15:226:15 | a | |
224+
| atl.cpp:220:10:220:10 | ref arg a | atl.cpp:241:3:241:3 | a | |
225+
| atl.cpp:221:5:221:5 | ref arg a | atl.cpp:222:10:222:10 | a | |
226+
| atl.cpp:221:5:221:5 | ref arg a | atl.cpp:226:15:226:15 | a | |
227+
| atl.cpp:221:5:221:5 | ref arg a | atl.cpp:241:3:241:3 | a | |
228+
| atl.cpp:222:10:222:10 | ref arg a | atl.cpp:226:15:226:15 | a | |
229+
| atl.cpp:222:10:222:10 | ref arg a | atl.cpp:241:3:241:3 | a | |
230+
| atl.cpp:224:20:224:21 | call to CAtlArray | atl.cpp:225:10:225:11 | a2 | |
231+
| atl.cpp:224:20:224:21 | call to CAtlArray | atl.cpp:226:5:226:6 | a2 | |
232+
| atl.cpp:224:20:224:21 | call to CAtlArray | atl.cpp:227:10:227:11 | a2 | |
233+
| atl.cpp:224:20:224:21 | call to CAtlArray | atl.cpp:231:13:231:14 | a2 | |
234+
| atl.cpp:224:20:224:21 | call to CAtlArray | atl.cpp:241:3:241:3 | a2 | |
235+
| atl.cpp:225:10:225:11 | ref arg a2 | atl.cpp:226:5:226:6 | a2 | |
236+
| atl.cpp:225:10:225:11 | ref arg a2 | atl.cpp:227:10:227:11 | a2 | |
237+
| atl.cpp:225:10:225:11 | ref arg a2 | atl.cpp:231:13:231:14 | a2 | |
238+
| atl.cpp:225:10:225:11 | ref arg a2 | atl.cpp:241:3:241:3 | a2 | |
239+
| atl.cpp:226:5:226:6 | ref arg a2 | atl.cpp:227:10:227:11 | a2 | |
240+
| atl.cpp:226:5:226:6 | ref arg a2 | atl.cpp:231:13:231:14 | a2 | |
241+
| atl.cpp:226:5:226:6 | ref arg a2 | atl.cpp:241:3:241:3 | a2 | |
242+
| atl.cpp:227:10:227:11 | ref arg a2 | atl.cpp:231:13:231:14 | a2 | |
243+
| atl.cpp:227:10:227:11 | ref arg a2 | atl.cpp:241:3:241:3 | a2 | |
244+
| atl.cpp:229:20:229:21 | call to CAtlArray | atl.cpp:230:10:230:11 | a3 | |
245+
| atl.cpp:229:20:229:21 | call to CAtlArray | atl.cpp:231:5:231:6 | a3 | |
246+
| atl.cpp:229:20:229:21 | call to CAtlArray | atl.cpp:232:10:232:11 | a3 | |
247+
| atl.cpp:229:20:229:21 | call to CAtlArray | atl.cpp:234:10:234:11 | a3 | |
248+
| atl.cpp:229:20:229:21 | call to CAtlArray | atl.cpp:235:11:235:12 | a3 | |
249+
| atl.cpp:229:20:229:21 | call to CAtlArray | atl.cpp:239:26:239:27 | a3 | |
250+
| atl.cpp:229:20:229:21 | call to CAtlArray | atl.cpp:241:3:241:3 | a3 | |
251+
| atl.cpp:230:10:230:11 | ref arg a3 | atl.cpp:231:5:231:6 | a3 | |
252+
| atl.cpp:230:10:230:11 | ref arg a3 | atl.cpp:232:10:232:11 | a3 | |
253+
| atl.cpp:230:10:230:11 | ref arg a3 | atl.cpp:234:10:234:11 | a3 | |
254+
| atl.cpp:230:10:230:11 | ref arg a3 | atl.cpp:235:11:235:12 | a3 | |
255+
| atl.cpp:230:10:230:11 | ref arg a3 | atl.cpp:239:26:239:27 | a3 | |
256+
| atl.cpp:230:10:230:11 | ref arg a3 | atl.cpp:241:3:241:3 | a3 | |
257+
| atl.cpp:231:5:231:6 | ref arg a3 | atl.cpp:232:10:232:11 | a3 | |
258+
| atl.cpp:231:5:231:6 | ref arg a3 | atl.cpp:234:10:234:11 | a3 | |
259+
| atl.cpp:231:5:231:6 | ref arg a3 | atl.cpp:235:11:235:12 | a3 | |
260+
| atl.cpp:231:5:231:6 | ref arg a3 | atl.cpp:239:26:239:27 | a3 | |
261+
| atl.cpp:231:5:231:6 | ref arg a3 | atl.cpp:241:3:241:3 | a3 | |
262+
| atl.cpp:232:10:232:11 | ref arg a3 | atl.cpp:234:10:234:11 | a3 | |
263+
| atl.cpp:232:10:232:11 | ref arg a3 | atl.cpp:235:11:235:12 | a3 | |
264+
| atl.cpp:232:10:232:11 | ref arg a3 | atl.cpp:239:26:239:27 | a3 | |
265+
| atl.cpp:232:10:232:11 | ref arg a3 | atl.cpp:241:3:241:3 | a3 | |
266+
| atl.cpp:234:10:234:11 | ref arg a3 | atl.cpp:235:11:235:12 | a3 | |
267+
| atl.cpp:234:10:234:11 | ref arg a3 | atl.cpp:239:26:239:27 | a3 | |
268+
| atl.cpp:234:10:234:11 | ref arg a3 | atl.cpp:241:3:241:3 | a3 | |
269+
| atl.cpp:235:11:235:12 | ref arg a3 | atl.cpp:239:26:239:27 | a3 | |
270+
| atl.cpp:235:11:235:12 | ref arg a3 | atl.cpp:241:3:241:3 | a3 | |
271+
| atl.cpp:235:14:235:20 | call to GetData | atl.cpp:235:10:235:22 | * ... | TAINT |
272+
| atl.cpp:237:20:237:21 | call to CAtlArray | atl.cpp:238:10:238:11 | a4 | |
273+
| atl.cpp:237:20:237:21 | call to CAtlArray | atl.cpp:239:5:239:6 | a4 | |
274+
| atl.cpp:237:20:237:21 | call to CAtlArray | atl.cpp:240:10:240:11 | a4 | |
275+
| atl.cpp:237:20:237:21 | call to CAtlArray | atl.cpp:241:3:241:3 | a4 | |
276+
| atl.cpp:238:10:238:11 | ref arg a4 | atl.cpp:239:5:239:6 | a4 | |
277+
| atl.cpp:238:10:238:11 | ref arg a4 | atl.cpp:240:10:240:11 | a4 | |
278+
| atl.cpp:238:10:238:11 | ref arg a4 | atl.cpp:241:3:241:3 | a4 | |
279+
| atl.cpp:239:5:239:6 | ref arg a4 | atl.cpp:240:10:240:11 | a4 | |
280+
| atl.cpp:239:5:239:6 | ref arg a4 | atl.cpp:241:3:241:3 | a4 | |
281+
| atl.cpp:239:26:239:27 | a3 | atl.cpp:239:25:239:27 | & ... | |
282+
| atl.cpp:240:10:240:11 | ref arg a4 | atl.cpp:241:3:241:3 | a4 | |
283+
| atl.cpp:243:20:243:21 | call to CAtlArray | atl.cpp:244:5:244:6 | a5 | |
284+
| atl.cpp:243:20:243:21 | call to CAtlArray | atl.cpp:245:10:245:11 | a5 | |
285+
| atl.cpp:243:20:243:21 | call to CAtlArray | atl.cpp:250:3:250:3 | a5 | |
286+
| atl.cpp:244:5:244:6 | ref arg a5 | atl.cpp:245:10:245:11 | a5 | |
287+
| atl.cpp:244:5:244:6 | ref arg a5 | atl.cpp:250:3:250:3 | a5 | |
288+
| atl.cpp:245:10:245:11 | ref arg a5 | atl.cpp:250:3:250:3 | a5 | |
289+
| atl.cpp:247:20:247:21 | call to CAtlArray | atl.cpp:248:5:248:6 | a6 | |
290+
| atl.cpp:247:20:247:21 | call to CAtlArray | atl.cpp:249:10:249:11 | a6 | |
291+
| atl.cpp:247:20:247:21 | call to CAtlArray | atl.cpp:250:3:250:3 | a6 | |
292+
| atl.cpp:248:5:248:6 | ref arg a6 | atl.cpp:249:10:249:11 | a6 | |
293+
| atl.cpp:248:5:248:6 | ref arg a6 | atl.cpp:250:3:250:3 | a6 | |
294+
| atl.cpp:249:10:249:11 | ref arg a6 | atl.cpp:250:3:250:3 | a6 | |
150295
| bsd.cpp:17:11:17:16 | call to source | bsd.cpp:20:18:20:18 | s | |
151296
| bsd.cpp:18:12:18:15 | addr | bsd.cpp:20:22:20:25 | addr | |
152297
| bsd.cpp:18:12:18:15 | addr | bsd.cpp:23:8:23:11 | addr | |

0 commit comments

Comments
 (0)