Skip to content

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

Closed
@lcartey

Description

@lcartey

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 
}

Metadata

Metadata

Assignees

Labels

Difficulty-HighA false positive or false negative report which is expected to take 1+ week effort to addressImpact-MediumPhase IIfalse positive/false negativeAn issue related to observed false positives or false negatives.user-reportIssue reported by an end user of CodeQL Coding Standards

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions