Read Time:42 Second

Description

The code uses an operator for assignment when the intention was to perform a comparison.

In many languages the compare statement is very close in appearance to the assignment statement and are often confused. This bug is generally the result of a typo and usually causes obvious problems with program execution. If the comparison is in an if statement, the if statement will usually evaluate the value of the right-hand side of the predicate.

Modes of Introduction:

– Implementation

 

Likelihood of Exploit: Low

 

Related Weaknesses

CWE-480
CWE-697

 

Consequences

Other: Alter Execution Logic

 

Potential Mitigations

Phase: Testing

Description: 

Many IDEs and static analysis products will detect this problem.

Phase: Implementation

Description: 

Place constants on the left. If one attempts to assign a constant with a variable, the compiler will produce an error.

CVE References