Attempt to Access Child of a Non-structure Pointer |
Weakness ID: 588 (Weakness Variant) | Status: Incomplete |
Description Summary
Casting a non-structure type to a structure type and accessing a field can lead to memory access errors or data corruption.
Scope | Effect |
---|---|
Integrity | Adjacent variables in memory may be corrupted by assignments performed on fields after the cast. |
Availability | Execution may end due to a memory access error. |
Example 1
(Bad Code)
Example Language: C
struct foo
{
int i;
}
...
int main(int argc, char **argv)
{
*foo = (struct foo *)main;
foo->i = 2;
return foo->i;
}
Requirements specification: The choice could be made to use a language that is not susceptible to these issues. |
Phase: Implementation Review of type casting operations can identify locations where incompatible types are cast. |
Nature | Type | ID | Name | View(s) this relationship pertains to![]() |
---|---|---|---|---|
ChildOf | ![]() | 465 | Pointer Issues | Development Concepts (primary)699 |
ChildOf | ![]() | 569 | Expression Issues | Development Concepts699 |
ChildOf | ![]() | 704 | Incorrect Type Conversion or Cast | Research Concepts (primary)1000 |
ChildOf | ![]() | 758 | Reliance on Undefined, Unspecified, or Implementation-Defined Behavior | Research Concepts1000 |
Modifications | ||||
---|---|---|---|---|
Modification Date | Modifier | Organization | Source | |
2008-07-01 | Eric Dalci | Cigital | External | |
updated Time of Introduction | ||||
2008-09-08 | CWE Content Team | MITRE | Internal | |
updated Relationships, Other Notes | ||||
2009-03-10 | CWE Content Team | MITRE | Internal | |
updated Relationships | ||||
2009-07-27 | CWE Content Team | MITRE | Internal | |
updated Common Consequences, Other Notes |