Difference between revisions of "Comparing instead of assigning"

From OWASP
Jump to: navigation, search
Line 1: Line 1:
 +
{{Template:Vulnerability}}
 
{{Template:SecureSoftware}}
 
{{Template:SecureSoftware}}
  
Line 63: Line 64:
  
 
[[Category:Vulnerability]]
 
[[Category:Vulnerability]]
 
 
[[Category:General Logic Error Vulnerability]]
 
[[Category:General Logic Error Vulnerability]]
 
 
[[Category:OWASP_CLASP_Project]]
 
[[Category:OWASP_CLASP_Project]]
 +
[[Category:Code Snippet]]
 +
[[Category:C]]

Revision as of 14:28, 7 August 2006

This is a Vulnerability. To view all vulnerabilities, please see the Vulnerability Category page.


Overview

In many languages, the compare statement is very close in appearance to the assignment statement; they are often confused.

Consequences

Unspecified.

Exposure period

  • Pre-design through Build: The use of tools to detect this problem is recommended.
  • Implementation: Many logic errors can lead to this condition. It can be exacerbated by lack, or misuse, of mitigating technologies.

Platform

  • Languages: C, C++, Java
  • Operating platforms: Any

Required resources

Any

Severity

High

Likelihood of exploit

Low

Avoidance and mitigation

  • Pre-design: Through Build: Many IDEs and static analysis products will detect this problem.

Discussion

This bug is mainly a typo and usually should cause obvious problems with program execution. The assignment will not always take place.

Examples

In C/C++/Java:

void called(int foo){
        foo==1;
        if (foo==1) printf("foo\n");
}

int main(){
        called(2);
        return 0;
}

Related problems

Assigning instead of comparing