Skip to content

PVS-Studio: fixed the potential vulnerability CWE-670 (Always-Incorrect Control Flow Implementation) #7909

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

Closed
wants to merge 1 commit into from

Conversation

IvanKishchenko
Copy link

We have found and fixed a vulnerability CWE-670 (Always-Incorrect Control Flow Implementation) using PVS-Studio tool.
Analyzer warnings: V3014, V3015 and V3081.
PVS-Studio is a static code analyzer for C, C++ and C#.

Fixes:

  • When comparing two statements through ExpressionEqualityComparer, the method GetHashCode was returning incorrect result for the expressions of the MemberInit with a list of arguments.
    We have written a unit test that proves that (See ExpressionCompareByHashCodeTest)
  • V3014 It is likely that a wrong variable is being incremented inside the 'for' operator. Consider reviewing 'i'. EFCore ExpressionEqualityComparer.cs 214
  • V3015 It is likely that a wrong variable is being compared inside the 'for' operator. Consider reviewing 'i' EFCore ExpressionEqualityComparer.cs 214
  • Also, we have corrected one of the unit tests, that was working incorrectly, to our mind.
  • V3081 The 'j' counter is not used inside a nested loop. Consider inspecting usage of 'i' counter. EFCore.Specification.Tests ComplexNavigationsQueryTestBase.cs 2393

@dnfclas
Copy link

dnfclas commented Mar 16, 2017

@IvanKishchenko,
Thanks for having already signed the Contribution License Agreement. Your agreement was validated by .NET Foundation. We will now review your pull request.
Thanks,
.NET Foundation Pull Request Bot

@IvanKishchenko IvanKishchenko changed the title PVS-Studio: fixed vulnerability CWE-670 (Always-Incorrect Control Flow Implementation) PVS-Studio: fixed the potential vulnerability CWE-670 (Always-Incorrect Control Flow Implementation) Mar 22, 2017
@dnfclas
Copy link

dnfclas commented Mar 23, 2017

@IvanKishchenko,
Thanks for having already signed the Contribution License Agreement. Your agreement was validated by .NET Foundation. We will now review your pull request.
Thanks,
.NET Foundation Pull Request Bot

@smitpatel
Copy link
Contributor

@IvanKishchenko - We wanted to test the functionality in terms of query pipeline and not just equality comparer to see functional impact of the error. Since the test was complicated to explain over forums, I added it myself. Though I have preserved your commit & it will be part of our code base.
Thank you for the contribution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants