Sitelet https://web.archive.org/web/20230714180940/https://github.com/github/codeql/pull/13669
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C++: Rewrite cpp/constant-array-overflow and add barriers #13669

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

MathiasVP
Copy link
Contributor

This PR splits the dataflow traversals in cpp/constant-array-overflow into multiple stages so that we can track the ArrayType as a flow state without introducing a cartesian product, and then adds a barrier that blocks flow in cases such as:

void foo(unsigned char* p, unsigned n) {
  if(n < 10) {
    unsigned char q = p[n]; // This is safe because the index is guarded to be less than 10 which happens to equal the size of buffer in `test`.
  }
}

void test(unsigned n) {
  unsigned char buffer[10];
  foo(buffer, n);
}

The first commit rewrites the query to track the array type as a FlowState, and the second commit adds the barrier that blocks out this flow.

@github-actions github-actions bot added the C++ label Jul 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant