CWE-588: Attempt to Access Child of a Non-structure Pointer

Description

Casting a non-structure type to a structure type and accessing a field can lead to memory access errors or data corruption.

Submission Date :

Dec. 15, 2006, midnight

Modification Date :

2023-10-26 00:00:00+00:00

Organization :

MITRE
Example Vulnerable Codes

Example - 1

The following example demonstrates the weakness.


int i;

*foo = (struct foo *)main;foo->i = 2;return foo->i;struct foo{}...int main(int argc, char **argv){}

Related Weaknesses

This table shows the weaknesses and high level categories that are related to this weakness. These relationships are defined to give an overview of the different insight to similar items that may exist at higher and lower levels of abstraction.

Visit http://cwe.mitre.org/ for more details.