This site is the archived OWASP Foundation Wiki and is no longer accepting Account Requests.
To view the new OWASP Foundation website, please visit https://owasp.org
Difference between revisions of "Code Correctness: Erroneous String Compare"
From OWASP
| Line 2: | Line 2: | ||
{{Template:Fortify}} | {{Template:Fortify}} | ||
| − | + | __TOC__ | |
| − | [[ | + | [[ASDR Table of Contents]] |
| − | |||
| − | |||
| + | Last revision (mm/dd/yy): '''{{REVISIONMONTH}}/{{REVISIONDAY}}/{{REVISIONYEAR}}''' | ||
==Description== | ==Description== | ||
| Line 94: | Line 93: | ||
[[Category:Implementation]] | [[Category:Implementation]] | ||
[[Category:Code Snippet]] | [[Category:Code Snippet]] | ||
| + | [[Category:Vulnerability]] | ||
Revision as of 11:59, 29 October 2008
This is a Vulnerability. To view all vulnerabilities, please see the Vulnerability Category page.
Last revision (mm/dd/yy): 10/29/2008
Description
Strings should be compared with the equals() method, not == or !=.
This program uses == or != to compare two strings for equality, which compares two objects for equality, not their values. Chances are good that the two references will never be equal.
Risk Factors
TBD
Examples
The following branch will never be taken.
if (args[0] == STRING_CONSTANT) {
logger.info("miracle");
}
Related Attacks
Related Vulnerabilities
Related Controls
Related Technical Impacts
References
Note: A reference to related CWE or CAPEC article should be added when exists. Eg: