diff --git a/test/constant_time/intraprocedural/struct/tainted_struct_compound_litteral.c b/test/constant_time/intraprocedural/struct/tainted_struct_compound_litteral.c new file mode 100644 index 0000000000000000000000000000000000000000..2fc44e95d908a82fc3ce72a07f59876a57fdec84 --- /dev/null +++ b/test/constant_time/intraprocedural/struct/tainted_struct_compound_litteral.c @@ -0,0 +1,22 @@ +struct foo { + int x; + int *z; +}; + +int main(void) { + int res = 0; + int y = 42; + struct foo __attribute__((__taint__)) bar; + bar = (struct foo){ y , &y }; + + if (bar.x) // Should be detected + res = 42; + + if (bar.z) // Should not be detected + res = 60; + + if (*bar.z) // Should be detected + res = 90; + + return res; +} diff --git a/test/constant_time/intraprocedural/struct/tainted_struct_compound_litteral_ptr.c b/test/constant_time/intraprocedural/struct/tainted_struct_compound_litteral_ptr.c new file mode 100644 index 0000000000000000000000000000000000000000..ed29c424655527302e2c530bebf4b496b7e207d6 --- /dev/null +++ b/test/constant_time/intraprocedural/struct/tainted_struct_compound_litteral_ptr.c @@ -0,0 +1,27 @@ +#include <stdlib.h> + +struct foo { + int x; + int *z; +}; + +int main(void) { + int res = 0; + int y = 42; + struct foo __attribute__((__taint__)) *bar = &((struct foo) { y, &y }); + + if (bar) { + + if (bar->x) // Should be detected + res = 42; + + if (bar->z) // Should not be detected + res = 60; + + if (*(bar->z)) // Should be detected + res = 90; + + } + + return res; +} diff --git a/test/constant_time/intraprocedural/struct/tainted_struct_ptr.c b/test/constant_time/intraprocedural/struct/tainted_struct_ptr.c new file mode 100644 index 0000000000000000000000000000000000000000..88d0992e8c17c708510be9b07950066c6f211ccc --- /dev/null +++ b/test/constant_time/intraprocedural/struct/tainted_struct_ptr.c @@ -0,0 +1,31 @@ +#include <stdlib.h> + +struct foo { + int x; + int *z; +}; + +int main(void) { + int res = 0; + int y = 42; + struct foo f; + struct foo __attribute__((__taint__)) *bar = &f; + + if (bar) { + + bar->x = y; + bar->z = &y; + + if (bar->x) // Should be detected + res = 42; + + if (bar->z) // Should not be detected + res = 60; + + if (*(bar->z)) // Should be detected + res = 90; + + } + + return res; +}