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 16:03, 22 May 2009 by Deleted user (talk | contribs)

Jump to: navigation, search

http://www.textriclisitd.com Template:CandidateForDeletion

#REDIRECT Failure to follow guideline/specification


Last revision (mm/dd/yy): 05/22/2009

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: