C++: tests for alias analysis of malloc

This commit is contained in:
Robert Marsh
2020-02-07 16:22:09 -08:00
parent 3c8aeb946a
commit 05c8610bbc
9 changed files with 217 additions and 0 deletions

View File

@@ -76,3 +76,16 @@ void guard() {
if (len > 1000) return;
char **node = (char **) malloc(len * sizeof(char *));
}
const char *alias_global;
void mallocBuffer() {
const char *userName = getenv("USER_NAME");
char *alias = (char*)malloc(4096);
char *copy = (char*)malloc(4096);
strcpy(copy, userName);
alias_global = alias; // to force a Chi node on all aliased memory
if (!strcmp(copy, "admin")) { // copy should be tainted
isAdmin = true;
}
}