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++: Fix regression from #18629 #18660

Merged
merged 1 commit into from
Feb 3, 2025
Merged

Conversation

MathiasVP
Copy link
Contributor

In #18629 we fixed a source of FPs in buffer-overflow queries that look like:

struct B { int c; };
struct A { B b; int x; };

A a;
memset(&a.b.c, 0, sizeof(A));

In order to compute the size of the buffer starting at c we compute the size of the "base" (in this case A) and subtract that from how far "we've gone" through the object.

This works fine on the above example, but when the code looks like:

struct B { int c; };
struct A { B b; int x; };

A* a = ...;
memset(a->b.c, 0, sizeof(A));

we need to strip the pointer off a in order to get the Class type.

We already have tests that would have caught this, but CI didn't run on #18629 which is why it was missed

@Copilot Copilot bot review requested due to automatic review settings February 3, 2025 12:48
@MathiasVP MathiasVP requested a review from a team as a code owner February 3, 2025 12:48
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 1 out of 1 changed files in this pull request and generated no comments.

Tip: If you use Visual Studio Code, you can request a review from Copilot before you push from the "Source Control" tab. Learn more

@github-actions github-actions bot added the C++ label Feb 3, 2025
@MathiasVP MathiasVP added the no-change-note-required This PR does not need a change note label Feb 3, 2025
Copy link
Contributor

@jketema jketema left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, provided DCA and tests come back good.

@jketema
Copy link
Contributor

jketema commented Feb 3, 2025

DCA looks good, and test pass.

@jketema jketema merged commit 5e92763 into github:main Feb 3, 2025
13 of 14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C++ no-change-note-required This PR does not need a change note
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants