Use of Pointer Subtraction to Determine Size |
Weakness ID: 469 (Weakness Base) | Status: Draft |
Description Summary
Scope | Effect |
---|---|
Authorization | There is the potential for arbitrary code execution with privileges of the vulnerable program. |
Pre-design through Build: Most static analysis programs should be able to catch these errors. |
Phase: 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. |
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. |
Nature | Type | ID | Name | View(s) this relationship pertains to![]() |
---|---|---|---|---|
ChildOf | ![]() | 465 | Pointer Issues | Development Concepts (primary)699 |
ChildOf | ![]() | 682 | Incorrect Calculation | Research Concepts (primary)1000 |
ChildOf | ![]() | 740 | CERT C Secure Coding Section 06 - Arrays (ARR) | Weaknesses Addressed by the CERT C Secure Coding Standard (primary)734 |
Mapped Taxonomy Name | Node ID | Fit | Mapped Node Name |
---|---|---|---|
CLASP | Improper pointer subtraction | ||
CERT C Secure Coding | ARR36-C | Do not subtract or compare two pointers that do not refer to the same array | |
CERT C Secure Coding | ARR37-C | Do not add or subtract an integer to a pointer to a non-array object |
A weakness where code path has: 1. end statement that subtracts pointer1 from pointer2 2. start statement that associates pointer1 with a memory chunk1 and pointer2 to a memory chunk2 3. memory chunk1 is not equal to the memory chunk2 |
Submissions | ||||
---|---|---|---|---|
Submission Date | Submitter | Organization | Source | |
CLASP | Externally Mined | |||
Modifications | ||||
Modification Date | Modifier | Organization | Source | |
2008-07-01 | Eric Dalci | Cigital | External | |
updated Time of Introduction | ||||
2008-08-01 | KDM Analytics | External | ||
added/updated white box definitions | ||||
2008-09-08 | CWE Content Team | MITRE | Internal | |
updated Applicable Platforms, Common Consequences, Relationships, Other Notes, Taxonomy Mappings | ||||
2008-11-24 | CWE Content Team | MITRE | Internal | |
updated Relationships, Taxonomy Mappings | ||||
Previous Entry Names | ||||
Change Date | Previous Entry Name | |||
2008-04-11 | Improper Pointer Subtraction | |||