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

M0-2-1: Consider array copies with overlapping data #119

Closed
lcartey opened this issue Nov 3, 2022 · 1 comment · Fixed by #637
Closed

M0-2-1: Consider array copies with overlapping data #119

lcartey opened this issue Nov 3, 2022 · 1 comment · Fixed by #637
Assignees
Labels
Difficulty-High A false positive or false negative report which is expected to take 1+ week effort to address false positive/false negative An issue related to observed false positives or false negatives. Impact-Medium Phase II user-report Issue reported by an end user of CodeQL Coding Standards

Comments

@lcartey
Copy link
Collaborator

lcartey commented Nov 3, 2022

Affected rules

  • M0-2-1

Description

The query as currently written only considers overlapping as caused by unions. We should also consider whether overlapping arrays are covered by the same rule.

Example

#include <cstring>
int16_t a[20];
void f2(void) {
  std::memcpy(&a[0], &a[1], 10u * sizeof(a[0]));  // Non-compliant
  std::memmove(&a[0], &a[1], 10u * sizeof(a[0])); // Compliant 
  std::memcpy(&a[1], &a[0], 10u * sizeof(a[0]));  // Non-compliant
  std::memmove(&a[1], &a[0], 10u * sizeof(a[0])); // Compliant 
}
@lcartey lcartey added false positive/false negative An issue related to observed false positives or false negatives. Difficulty-High A false positive or false negative report which is expected to take 1+ week effort to address Impact-Medium user-report Issue reported by an end user of CodeQL Coding Standards labels Nov 3, 2022
@rvermeulen rvermeulen moved this from Triaged to Scheduled in Coding Standards Public Development Board Apr 2, 2024
@knewbury01 knewbury01 assigned knewbury01 and unassigned rvermeulen Apr 24, 2024
@knewbury01 knewbury01 moved this from Scheduled to In Progress in Coding Standards Public Development Board Jun 14, 2024
@knewbury01
Copy link
Contributor

is this suggestion actually about checking for UB in some set of pointer handling functions?
(like how use of overlapping objects in memcpy is UB?)

perhaps one way forward is to look for cases in a list of functions that would have restrict qualified pointers in c?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Difficulty-High A false positive or false negative report which is expected to take 1+ week effort to address false positive/false negative An issue related to observed false positives or false negatives. Impact-Medium Phase II user-report Issue reported by an end user of CodeQL Coding Standards
Projects
Development

Successfully merging a pull request may close this issue.

3 participants