codeql-coding-standards icon indicating copy to clipboard operation
codeql-coding-standards copied to clipboard

`M0-2-1`: Consider expanding to inter-procedural overlapping analysis

Open lcartey opened this issue 2 years ago • 0 comments

Affected rules

  • M0-2-1

Description

The query currently identifies objects using an intra-procedural technique - we only check for equivalence of objects within the same function. We should consider expanding to support analysis across functions.

Example

struct s1 {
  int m1[10];
};
struct s2 {
  int m1;
  struct s1 m2;
};

union u {
  struct s1 m1;
  struct s2 m2;
};

void overlapping_access(u u1, u u2) {
  u1.m2.m2 = u2.m1; // NON_COMPLIANT when called from test
}

void test() {
 u1 u;
 overlapping_access(u, u)
}

lcartey avatar Nov 03 '22 10:11 lcartey