Common typo patterns that change application logic

ID

c.miscellaneous.typos

Severity

low

Resource

Miscellaneous

Language

C / C++

Description

The programmer accidentally uses the wrong operator, which changes the application logic in security-relevant ways. This rule also covers some other common typo patterns.

Rationale

The programmer accidentally uses the wrong operator, which changes the application logic in security-relevant ways. This rule also covers some other common typo patterns.

The following code illustrates a vulnerable pattern detected by this rule:

int left;

while (*src && left)
{
	*dst++ = *src++;
	// VULNERABLE: Common typo patterns that change application logic
	if (left = 0)
	{
		die("badlen");
	}
	left--;
}

Remediation

Follow secure coding practices and review the references below for detailed remediation guidance.

Configuration

This detector does not need any configuration.