mirror of
https://github.com/github/codeql.git
synced 2026-04-29 10:45:15 +02:00
C++: Simplify field conflation test
It turned out the `memcpy` step was not even necessary.
This commit is contained in:
@@ -99,21 +99,21 @@ void test_outparams() {
|
||||
}
|
||||
|
||||
|
||||
void *memcpy(void *dst, void *src, int size);
|
||||
|
||||
struct ContainsArray {
|
||||
int arr[16];
|
||||
|
||||
struct XY {
|
||||
int x;
|
||||
int y;
|
||||
};
|
||||
|
||||
void taint_array(ContainsArray *ca, int offset) {
|
||||
void taint_y(XY *xyp) {
|
||||
int tainted = getenv("VAR")[0];
|
||||
memcpy(ca->arr + offset, &tainted, sizeof(int));
|
||||
xyp->y = tainted;
|
||||
}
|
||||
|
||||
void test_conflated_fields3(int arbitrary) {
|
||||
ContainsArray ca;
|
||||
ca.x = 0;
|
||||
taint_array(&ca, arbitrary);
|
||||
sink(ca.x); // not tainted [FALSE POSITIVE]
|
||||
void test_conflated_fields3() {
|
||||
XY xy;
|
||||
xy.x = 0;
|
||||
taint_y(&xy);
|
||||
sink(xy.x); // not tainted [FALSE POSITIVE]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user