Skip to content

C/C++: Detect ambiguous assignment of comparison results - #22336

Open
theinfosecguy wants to merge 1 commit into
github:mainfrom
theinfosecguy:cpp-ambiguous-assignment-condition
Open

C/C++: Detect ambiguous assignment of comparison results#22336
theinfosecguy wants to merge 1 commit into
github:mainfrom
theinfosecguy:cpp-ambiguous-assignment-condition

Conversation

@theinfosecguy

Copy link
Copy Markdown
Contributor

Adds cpp/ambiguous-assignment-of-comparison to flag conditions such as:

if ((status = read_status() < 0))

The query distinguishes this from explicitly grouped assign-then-compare and compare-then-assign expressions. It includes C and C++ tests, query help, and query-suite integration.

Local targeted and neighboring tests pass. The motivating regression is detected, and a run against git/git produced no alerts.

Fixes #22286

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

C: Implicit compare-then-assign in branch conditions should be flagged

1 participant