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

Code Correctness: Erroneous String Compare

From OWASP
Revision as of 17:52, 19 July 2006 by Weilin Zhong (talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

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

This article includes content generously donated to OWASP by MicroFocus Logo.png

Abstract

Strings should be compared with the equals() method, not == or !=.

Description

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.

Examples

The following branch will never be taken.

	  if (args[0] == STRING_CONSTANT) {
		  logger.info("miracle");
	  }

Related Threats

Related Attacks

Related Vulnerabilities

Related Countermeasures

Categories