The programmer accidentally uses the wrong operator, which
changes the application logic in security-relevant ways.
Time of Introduction
Implementation
Applicable Platforms
Languages
C: (Sometimes)
C++: (Sometimes)
Perl: (Sometimes)
All
Likelihood of Exploit
Low
Demonstrative Examples
Example 1
C
char foo;
foo=a+c;
Potential Mitigations
Phase
Description
Pre-design through Build: Most static analysis programs should be able
to catch these errors.
Implementation
Save an index variable. This is the recommended solution. Rather than
subtract pointers from one another, use an index variable of the same
size as the pointers in question. Use this variable to "walk" from one
pointer to the other and calculate the difference. Always sanity check
this number.
Other Notes
These types of bugs generally are the result of a typo. Although most of
them can easily be found when testing of the program, it is important that
one correct these problems, since they almost certainly will break the
code.