1108
Nature Type ID Name Page
PeerOf 170 Improper Null Termination 428
PeerOf 463 Deletion of Data Structure Sentinel 1105
Relevant to the view "Software Development" (CWE-699)
Nature Type ID Name Page
MemberOf 137 Data Neutralization Issues 2311
Applicable Platforms
Language : C (Prevalence = Undetermined)
Language : C++ (Prevalence = Undetermined)
Likelihood Of Exploit
High
Common Consequences
Scope Impact Likelihood
Integrity Modify Application Data
Generally this error will cause the data structure to not
work properly by truncating the data.
Potential Mitigations
Phase: Implementation
Phase: Architecture and Design
Encapsulate the user from interacting with data sentinels. Validate user input to verify that
sentinels are not present.
Phase: Implementation
Proper error checking can reduce the risk of inadvertently introducing sentinel values into data.
For example, if a parsing function fails or encounters an error, it might return a value that is the
same as the sentinel.
Phase: Architecture and Design
Use an abstraction library to abstract away risky APIs. This is not a complete solution.
Phase: Operation
Use OS-level preventative functionality. This is not a complete solution.
Demonstrative Examples
Example 1:
The following example assigns some character values to a list of characters and prints them each
individually, and then as a string. The third character value is intended to be an integer taken from
user input and converted to an int.
Example Language: C (Bad)
char *foo;
foo=malloc(sizeof(char)*5);
foo[0]='a';
foo[1]='a';
foo[2]=atoi(getc(stdin));
foo[3]='c';
foo[4]='\0'
printf("%c %c %c %c %c \n",foo[0],foo[1],foo[2],foo[3],foo[4]);
printf("%s\n",foo);
CWE Version 4.14
CWE-466: Return of Pointer Value Outside of Expected Range
CWE-466: Return of Pointer Value Outside of Expected Range