CPP: Add tests for strdup.

This commit is contained in:
Geoffrey White
2020-01-15 18:24:13 +00:00
parent b8ee5a63db
commit ce389ca791
2 changed files with 53 additions and 0 deletions

View File

@@ -324,3 +324,19 @@
| taint.cpp:347:13:347:13 | d | taint.cpp:347:12:347:13 | & ... | |
| taint.cpp:348:14:348:14 | ref arg e | taint.cpp:355:7:355:7 | e | |
| taint.cpp:348:17:348:17 | ref arg t | taint.cpp:350:7:350:7 | t | |
| taint.cpp:365:24:365:29 | source | taint.cpp:369:13:369:18 | source | |
| taint.cpp:365:24:365:29 | source | taint.cpp:371:14:371:19 | source | |
| taint.cpp:369:6:369:11 | call to strdup | taint.cpp:369:2:369:19 | ... = ... | |
| taint.cpp:369:6:369:11 | call to strdup | taint.cpp:372:7:372:7 | a | |
| taint.cpp:370:6:370:11 | call to strdup | taint.cpp:370:2:370:27 | ... = ... | |
| taint.cpp:370:6:370:11 | call to strdup | taint.cpp:373:7:373:7 | b | |
| taint.cpp:371:6:371:12 | call to strndup | taint.cpp:371:2:371:25 | ... = ... | |
| taint.cpp:371:6:371:12 | call to strndup | taint.cpp:374:7:374:7 | c | |
| taint.cpp:377:23:377:28 | source | taint.cpp:381:30:381:35 | source | |
| taint.cpp:381:6:381:12 | call to strndup | taint.cpp:381:2:381:36 | ... = ... | |
| taint.cpp:381:6:381:12 | call to strndup | taint.cpp:382:7:382:7 | a | |
| taint.cpp:385:27:385:32 | source | taint.cpp:389:13:389:18 | source | |
| taint.cpp:389:6:389:11 | call to wcsdup | taint.cpp:389:2:389:19 | ... = ... | |
| taint.cpp:389:6:389:11 | call to wcsdup | taint.cpp:391:7:391:7 | a | |
| taint.cpp:390:6:390:11 | call to wcsdup | taint.cpp:390:2:390:28 | ... = ... | |
| taint.cpp:390:6:390:11 | call to wcsdup | taint.cpp:392:7:392:7 | b | |

View File

@@ -354,3 +354,40 @@ void test_outparams()
sink(d); // tainted [NOT DETECTED]
sink(e);
}
// --- strdup ---
typedef unsigned long size_t;
char *strdup(const char *s1);
char *strndup(const char *s1, size_t n);
wchar_t* wcsdup(const wchar_t* s1);
void test_strdup(char *source)
{
char *a, *b, *c;
a = strdup(source);
b = strdup("hello, world");
c = strndup(source, 100);
sink(a); // tainted [NOT DETECTED]
sink(b);
sink(c); // tainted [NOT DETECTED]
}
void test_strndup(int source)
{
char *a;
a = strndup("hello, world", source);
sink(a);
}
void test_wcsdup(wchar_t *source)
{
wchar_t *a, *b;
a = wcsdup(source);
b = wcsdup(L"hello, world");
sink(a); // tainted [NOT DETECTED]
sink(b);
}