<?xml version="1.0" encoding="UTF-8"?>

        <Weakness_Catalog xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://cwe.mitre.org/data/xsd/cwe_schema_v3.0.xsd" Catalog_Version="0.9" Catalog_Name="CWE-658: Weaknesses found in the C Language ">
	<Views/>
	<Categories>
                    <Category Category_ID="192" Category_Name="Integer Coercion Error" Category_Status="Incomplete">
		<Common_Attributes>
			<Description>
				<Description_Summary>Integer coercion refers to a set of flaws pertaining to the type casting, extension, or
				truncation of primitive data types.</Description_Summary>
			</Description>
			<Likelihood_of_Exploit>Medium</Likelihood_of_Exploit>
			<Common_Consequences>
				<Common_Consequence>Availability: Integer coercion often leads to undefined states of execution
					resulting in infinite loops or crashes.</Common_Consequence>
				<Common_Consequence>Access Control: In some cases, integer coercion errors can lead to exploitable
					buffer overflow conditions, resulting in the execution of arbitrary code.</Common_Consequence>
				<Common_Consequence>Integrity: Integer coercion errors result in an incorrect value being stored
					for the variable in question.</Common_Consequence>
			</Common_Consequences>
			<Potential_Mitigations>
				<Mitigation>Requirements specification: A language which throws exceptions on ambiguous data casts
					might be chosen.</Mitigation>
				<Mitigation>Design: Design objects and program flow such that multiple or complex casts are
					unnecessary</Mitigation>
				<Mitigation>Implementation: Ensure that any data type casting that you must used is entirely
					understood in order to reduce the plausibility of error in use.</Mitigation>
			</Potential_Mitigations>
			<Demonstrative_Example>
				<Example_Code>
					<PreText>See the Examples section of the problem type Unsigned to signed conversion error for
						an example of integer coercion errors.</PreText>
				</Example_Code>
			</Demonstrative_Example>
			<Context_Notes>Several flaws fall under the category of integer coercion errors. For the most part,
				these errors in and of themselves result only in availability and data integrity issues. However,
				in some circumstances, they may result in other, more complicated security related flaws, such as
				buffer overflow conditions.</Context_Notes>
				<Relationships>
				<Relationship>
						<Relationship_Views>
							<Relationship_View_ID Ordinal="Primary">1000</Relationship_View_ID>
						</Relationship_Views>
						<Relationship_Type>Category</Relationship_Type>
					<Relationship_Nature>ChildOf</Relationship_Nature>
					<Relationship_Target_ID>189</Relationship_Target_ID>
				</Relationship>
				<Relationship>
						<Relationship_Views>
							<Relationship_View_ID>1000</Relationship_View_ID>
						</Relationship_Views>
						<Relationship_Type>Weakness</Relationship_Type>
					<Relationship_Nature>CanAlsoBe</Relationship_Nature>
					<Relationship_Target_ID>195</Relationship_Target_ID>
				</Relationship>
				<Relationship>
						<Relationship_Views>
							<Relationship_View_ID>1000</Relationship_View_ID>
						</Relationship_Views>
						<Relationship_Type>Weakness</Relationship_Type>
					<Relationship_Nature>CanAlsoBe</Relationship_Nature>
					<Relationship_Target_ID>196</Relationship_Target_ID>
				</Relationship>
				<Relationship>
						<Relationship_Views>
							<Relationship_View_ID>1000</Relationship_View_ID>
						</Relationship_Views>
						<Relationship_Type>Weakness</Relationship_Type>
					<Relationship_Nature>CanAlsoBe</Relationship_Nature>
					<Relationship_Target_ID>197</Relationship_Target_ID>
				</Relationship>
				<Relationship>
						<Relationship_Views>
							<Relationship_View_ID>1000</Relationship_View_ID>
						</Relationship_Views>
						<Relationship_Type>Weakness</Relationship_Type>
					<Relationship_Nature>CanAlsoBe</Relationship_Nature>
					<Relationship_Target_ID>194</Relationship_Target_ID>
				</Relationship>
				</Relationships>
			<Source_Taxonomy Source_Taxonomy_Name="CLASP">
				<Original_Node_Name>Integer coercion error</Original_Node_Name>
			</Source_Taxonomy>
			<Applicable_Platforms>
				<Platform>C</Platform>
				<Platform>C++</Platform>
				<Platform>Java</Platform>
				<Platform>.NET</Platform>
			</Applicable_Platforms>
			<Time_of_Introduction>Implementation</Time_of_Introduction>
		</Common_Attributes>
	</Category>
                    <Category Category_ID="251" Category_Name="Often Misused: String Management" Category_Status="Incomplete">
		<Common_Attributes>
			<Description>
				<Description_Summary>Functions that manipulate strings encourage buffer overflows.</Description_Summary>
			</Description>
			<Affected_Resource>Memory</Affected_Resource>
			<Demonstrative_Example>
				<Example_Code>
					<PreText>Windows provides the _mbs family of functions to perform various operations on
						multibyte strings. When these functions are passed a malformed multibyte string, such as a
						string containing a valid leading byte followed by a single null byte, they can read or
						write past the end of the string buffer causing a buffer overflow. The following functions
						all pose a risk of buffer overflow: _mbsinc _mbsdec _mbsncat _mbsncpy _mbsnextc _mbsnset
						_mbsrev _mbsset _mbsstr _mbstok _mbccpy _mbslen </PreText>
				</Example_Code>
			</Demonstrative_Example>
				<Relationships>
				<Relationship>
						<Relationship_Views>
							<Relationship_View_ID Ordinal="Primary">1000</Relationship_View_ID>
						</Relationship_Views>
						<Relationship_Type>Category</Relationship_Type>
					<Relationship_Nature>ChildOf</Relationship_Nature>
					<Relationship_Target_ID>133</Relationship_Target_ID>
				</Relationship>
				<Relationship>
						<Relationship_Views>
							<Relationship_View_ID Ordinal="Primary">630</Relationship_View_ID>
						</Relationship_Views>
						<Relationship_Type>View</Relationship_Type>
					<Relationship_Nature>ChildOf</Relationship_Nature>
					<Relationship_Target_ID>630</Relationship_Target_ID>
				</Relationship>
				<Relationship>
						<Relationship_Views>
							<Relationship_View_ID Ordinal="Primary">631</Relationship_View_ID>
						</Relationship_Views>
						<Relationship_Type>Category</Relationship_Type>
					<Relationship_Nature>ChildOf</Relationship_Nature>
					<Relationship_Target_ID>633</Relationship_Target_ID>
				</Relationship>
				</Relationships>
			<Source_Taxonomy Source_Taxonomy_Name="7 Pernicious Kingdoms">
				<Original_Node_Name>Often Misused: Strings</Original_Node_Name>
			</Source_Taxonomy>
			<Applicable_Platforms>
				<Platform>C</Platform>
				<Platform>C++</Platform>
			</Applicable_Platforms>
		</Common_Attributes>
	</Category></Categories>
	<Weaknesses>
                    <Weakness Weakness_ID="121" Weakness_Name="Stack-based Buffer Overflow" Weakness_Abstraction="Variant" Weakness_Status="Draft">
		<Common_Attributes>
			<Description>
				<Description_Summary>A stack-based buffer overflow condition is a condition where the buffer being overwritten
				is allocated on the stack (i.e., is a local variable or, rarely, a parameter to a function).</Description_Summary>
			</Description>
			<Alternate_Terms>Stack Overflow</Alternate_Terms>
			<Likelihood_of_Exploit>Very high</Likelihood_of_Exploit>
			<Weakness_Ordinality>Primary (Weakness exists independent of other weaknesses)</Weakness_Ordinality>
			<Causal_Nature>Explicit (This is an explicit weakness resulting from behavior of the developer)</Causal_Nature>
			<Common_Consequences>
				<Common_Consequence>Availability: Buffer overflows generally lead to crashes. Other attacks
					leading to lack of availability are possible, including putting the program into an infinite
					loop.</Common_Consequence>
				<Common_Consequence>Access control (memory and instruction processing): Buffer overflows often can
					be used to execute arbitrary code, which is usually outside the scope of a program's implicit
					security policy.</Common_Consequence>
				<Common_Consequence>Other: When the consequence is arbitrary code execution, this can often be
					used to subvert any other security service.</Common_Consequence>
			</Common_Consequences>
			<Potential_Mitigations>
				<Mitigation>Pre-design: Use a language or compiler that performs automatic bounds checking.</Mitigation>
				<Mitigation>Design: Use an abstraction library to abstract away risky APIs. Not a complete
					solution.</Mitigation>
				<Mitigation>Pre-design through Build: Compiler-based canary mechanisms such as StackGuard,
					ProPolice and the Microsoft Visual Studio /GS flag. Unless this provides automatic bounds
					checking, it is not a complete solution.</Mitigation>
				<Mitigation>Operational: Use OS-level preventative functionality. Not a complete
				solution.</Mitigation>
			</Potential_Mitigations>
			<Demonstrative_Example>
				<Example_Code>
					<PreText>While buffer overflow examples can be rather complex, it is possible to have very
						simple, yet still exploitable, stack-based buffer overflows:</PreText>
					<Example_Block>
						<Example_Code_Block>
							<Code_Example_Language>C</Code_Example_Language>
							<Code_Block><![CDATA[#define]]><![CDATA[ BUFSIZE 256
					
					int main]]><![CDATA[(int argc, char **argv) {
					 ]]><![CDATA[ char buf[BUFSIZE];
					
					 ]]><![CDATA[ strcpy(buf, argv[1]);
					}]]></Code_Block>
						</Example_Code_Block>
					</Example_Block>
				</Example_Code>
			</Demonstrative_Example>
			<Context_Notes>There are generally several security-critical data on an execution stack that can lead
				to arbitrary code execution. The most prominent is the stored return address, the memory address
				at which execution should continue once the current function is finished executing. The attacker
				can overwrite this value with some memory address to which the attacker also has write access,
				into which he places arbitrary code to be run with the full privileges of the vulnerable program.
				Alternately, the attacker can supply the address of an important call, for instance the POSIX
				system() call, leaving arguments to the call on the stack. This is often called a return into libc
				exploit, since the attacker generally forces the program to jump at return time into an
				interesting routine in the C standard library (libc). Other important data commonly on the stack
				include the stack pointer and frame pointer, two values that indicate offsets for computing memory
				addresses. Modifying those values can often be leveraged into a "write-what-where" condition.</Context_Notes>
			<Context_Notes>Stack-based buffer overflows can instantiate in return address overwrites, stack
				pointer overwrites or frame pointer overwrites. They can also be considered function pointer
				overwrites, array indexer overwrites or write-what-where condition, etc.</Context_Notes>
			<Context_Notes>Terminology Note: "Stack Overflow" is often used to mean the same thing as stack-based
				buffer overflow, however it is also used on occasion to mean stack exhaustion, usually a result
				from an excessively recursive function call. Due to the ambiguity of the term, use of stack
				overflow to describe either circumstance is discouraged.</Context_Notes>
				<Relationships>
				<Relationship>
						<Relationship_Views>
							<Relationship_View_ID Ordinal="Primary">1000</Relationship_View_ID>
						</Relationship_Views>
						<Relationship_Type>Compound_Element</Relationship_Type>
					<Relationship_Nature>ChildOf</Relationship_Nature>
					<Relationship_Target_ID>120</Relationship_Target_ID>
				</Relationship>
				<Relationship>
						<Relationship_Views>
							<Relationship_View_ID Ordinal="Primary">630</Relationship_View_ID>
						</Relationship_Views>
						<Relationship_Type>View</Relationship_Type>
					<Relationship_Nature>ChildOf</Relationship_Nature>
					<Relationship_Target_ID>630</Relationship_Target_ID>
				</Relationship>
				</Relationships>
			<Source_Taxonomy Source_Taxonomy_Name="CLASP">
				<Original_Node_Name>Stack overflow</Original_Node_Name>
			</Source_Taxonomy>
			<Applicable_Platforms>
				<Platform>C</Platform>
				<Platform>C++</Platform>
			</Applicable_Platforms>
			<Time_of_Introduction>Implementation</Time_of_Introduction>
			<White_Box_Definition>
	A buffer overflow where the buffer from the Buffer Write Operation is statically allocated
			</White_Box_Definition>
		</Common_Attributes>
	</Weakness>
                    <Weakness Weakness_ID="122" Weakness_Name="Heap-based Buffer Overflow" Weakness_Abstraction="Variant" Weakness_Status="Draft">
		<Common_Attributes>
			<Description>
				<Description_Summary>A heap overflow condition is a buffer overflow, where the buffer that can be overwritten
				is allocated in the heap portion of memory, generally meaning that the buffer was allocated using
				a routine such as malloc().</Description_Summary>
			</Description>
			<Likelihood_of_Exploit>High to Very High</Likelihood_of_Exploit>
			<Weakness_Ordinality>Primary (Weakness exists independent of other weaknesses)</Weakness_Ordinality>
			<Causal_Nature>Explicit (This is an explicit weakness resulting from behavior of the developer)</Causal_Nature>
			<Affected_Resource>Memory</Affected_Resource>
			<Common_Consequences>
				<Common_Consequence>Availability: Buffer overflows generally lead to crashes. Other attacks
					leading to lack of availability are possible, including putting the program into an infinite
					loop.</Common_Consequence>
				<Common_Consequence>Access control (memory and instruction processing): Buffer overflows often can
					be used to execute arbitrary code, which is usually outside the scope of a program's implicit
					security policy.</Common_Consequence>
				<Common_Consequence>Other: When the consequence is arbitrary code execution, this can often be
					used to subvert any other security service.</Common_Consequence>
			</Common_Consequences>
			<Potential_Mitigations>
				<Mitigation>Pre-design: Use a language or compiler that performs automatic bounds checking.</Mitigation>
				<Mitigation>Design: Use an abstraction library to abstract away risky APIs. Not a complete
					solution.</Mitigation>
				<Mitigation>Pre-design through Build: Canary style bounds checking, library changes which ensure
					the validity of chunk data, and other such fixes are possible, but should not be relied upon.</Mitigation>
				<Mitigation>Operational: Use OS-level preventative functionality. Not a complete
				solution.</Mitigation>
			</Potential_Mitigations>
			<Demonstrative_Example>
				<Example_Code>
					<PreText/>
					<Example_Block>
						<Example_Code_Block>
							<Code_Example_Language>C</Code_Example_Language>
							<Code_Block><![CDATA[#define BUFSIZE 256
				
	]]><![CDATA[			int main(int argc, char **arg]]><![CDATA[v) {
				  char *buf;
				
				 ]]><![CDATA[ buf = (char *)malloc(BUFSIZE);
]]><![CDATA[				  strcpy(buf, argv[1]);
				]]><![CDATA[}]]></Code_Block>
						</Example_Code_Block>
					</Example_Block>
				</Example_Code>
			</Demonstrative_Example>
			<Observed_Examples>
				<Observed_Example>
					<Observed_Example_Reference>CVE-2007-4268</Observed_Example_Reference>
					<Observed_Example_Description>Chain: integer signedness passes signed comparison, leads to
						heap overflow</Observed_Example_Description>
				</Observed_Example>
			</Observed_Examples>
			<Context_Notes>Heap-based buffer overflows are usually just as dangerous as stack-based buffer
				overflows. Besides important user data, heap-based overflows can be used to overwrite function
				pointers that may be living in memory, pointing it to the attacker's code. Even in applications
				that do not explicitly use function pointers, the run-time will usually leave many in memory. For
				example, object methods in C++ are generally implemented using function pointers. Even in C
				programs, there is often a global offset table used by the underlying runtime.</Context_Notes>
				<Relationships>
				<Relationship>
						<Relationship_Views>
							<Relationship_View_ID Ordinal="Primary">1000</Relationship_View_ID>
						</Relationship_Views>
						<Relationship_Type>Compound_Element</Relationship_Type>
					<Relationship_Nature>ChildOf</Relationship_Nature>
					<Relationship_Target_ID>120</Relationship_Target_ID>
				</Relationship>
				<Relationship>
						<Relationship_Views>
							<Relationship_View_ID Ordinal="Primary">630</Relationship_View_ID>
						</Relationship_Views>
						<Relationship_Type>View</Relationship_Type>
					<Relationship_Nature>ChildOf</Relationship_Nature>
					<Relationship_Target_ID>630</Relationship_Target_ID>
				</Relationship>
				<Relationship>
						<Relationship_Views>
							<Relationship_View_ID Ordinal="Primary">631</Relationship_View_ID>
						</Relationship_Views>
						<Relationship_Type>Category</Relationship_Type>
					<Relationship_Nature>ChildOf</Relationship_Nature>
					<Relationship_Target_ID>633</Relationship_Target_ID>
				</Relationship>
				</Relationships>
			<Source_Taxonomy Source_Taxonomy_Name="CLASP">
				<Original_Node_Name>Heap overflow</Original_Node_Name>
			</Source_Taxonomy>
			<Applicable_Platforms>
				<Platform>C</Platform>
				<Platform>C++</Platform>
			</Applicable_Platforms>
			<Time_of_Introduction>Implementation</Time_of_Introduction>
			<Related_Attack_Patterns>
				<Related_Attack_Pattern>
					<CAPEC_ID>92<!--Forced Integer Overflow--></CAPEC_ID>
				</Related_Attack_Pattern>
			</Related_Attack_Patterns>
			<White_Box_Definition>
	A buffer overflow where the buffer from the Buffer Write Operation is dynamically allocated
			</White_Box_Definition>
		</Common_Attributes>
	</Weakness>
                    <Weakness Weakness_ID="123" Weakness_Name="Write-what-where Condition" Weakness_Abstraction="Base" Weakness_Status="Draft">
		<Common_Attributes>
			<Description>
				<Description_Summary>Any condition where the attacker has the ability to write an arbitrary value to an
				arbitrary location, often as the result of a buffer overflow.</Description_Summary>
			</Description>
			<Likelihood_of_Exploit>High</Likelihood_of_Exploit>
			<Weakness_Ordinality>Resultant (Weakness is typically related to the presence of some other weaknesses)</Weakness_Ordinality>
			<Causal_Nature>Explicit (This is an explicit weakness resulting from behavior of the developer)</Causal_Nature>
			<Common_Consequences>
				<Common_Consequence>Access control (memory and instruction processing): Clearly, write-what-where
					conditions can be used to write data to areas of memory outside the scope of a policy. Also,
					they almost invariably can be used to execute arbitrary code, which is usually outside the
					scope of a program's implicit security policy.</Common_Consequence>
				<Common_Consequence>Availability: Many memory accesses can lead to program termination, such as
					when writing to addresses that are invalid for the current process.</Common_Consequence>
				<Common_Consequence>Other: When the consequence is arbitrary code execution, this can often be
					used to subvert any other security service.</Common_Consequence>
			</Common_Consequences>
			<Potential_Mitigations>
				<Mitigation>Pre-design: Use a language that provides appropriate memory abstractions.</Mitigation>
				<Mitigation>Design: Integrate technologies that try to prevent the consequences of this problem.</Mitigation>
				<Mitigation>Implementation: Take note of mitigations provided for other flaws in this taxonomy
					that lead to write-what-where conditions.</Mitigation>
				<Mitigation>Operational: Use OS-level preventative functionality integrated after the fact. Not a
					complete solution.</Mitigation>
			</Potential_Mitigations>
			<Context_Notes>When the attacker has the ability to write arbitrary data to an arbitrary location in
				memory, the consequences are often arbitrary code execution. If the attacker can overwrite a
				pointer's worth of memory (usually 32 or 64 bits), he can redirect a function pointer to his own
				malicious code. Even when the attacker can only modify a single byte using a write-what-where
				problem, arbitrary code execution can be possible. Sometimes this is because the same problem can
				be exploited repeatedly to the same effect. Other times it is because the attacker can overwrite
				security-critical application-specific data -- such as a flag indicating whether the user is an
				administrator.</Context_Notes>
				<Relationships>
				<Relationship>
						<Relationship_Views>
							<Relationship_View_ID Ordinal="Primary">1000</Relationship_View_ID>
						</Relationship_Views>
						<Relationship_Type>Weakness</Relationship_Type>
					<Relationship_Nature>ChildOf</Relationship_Nature>
					<Relationship_Target_ID>119</Relationship_Target_ID>
				</Relationship>
				<Relationship>
						<Relationship_Views>
							<Relationship_View_ID>1000</Relationship_View_ID>
						</Relationship_Views>
						<Relationship_Type>Weakness</Relationship_Type>
					<Relationship_Nature>PeerOf</Relationship_Nature>
					<Relationship_Target_ID>134</Relationship_Target_ID>
				</Relationship>
				</Relationships>
			<Source_Taxonomy Source_Taxonomy_Name="CLASP">
				<Original_Node_Name>Write-what-where condition</Original_Node_Name>
			</Source_Taxonomy>
			<Applicable_Platforms>
				<Platform>C</Platform>
				<Platform>C++</Platform>
			</Applicable_Platforms>
		</Common_Attributes>
	</Weakness>
                    <Weakness Weakness_ID="124" Weakness_Name="Boundary Beginning Violation ('Buffer Underwrite')" Weakness_Abstraction="Base" Weakness_Status="Incomplete">
		<Common_Attributes>
			<Description>
				<Description_Summary>The software allows a condition where buffers are written to using buffer access mechanisms such as indexes or pointers that reference memory locations prior to the targeted buffer. This typically occurs when indexes are negative numbers or when pointer arithmetic results in a position before the beginning of the valid memory location. This can occur when a negative number is used as an offset, or if the pointer or its index is decremented to a position before the buffer.</Description_Summary>
			</Description>
			<Alternate_Terms>Some prominent vendors and researchers use the term "buffer underrun". "Buffer
				underflow" is more commonly used, although both terms are also sometimes used to describe a buffer
				under-read (CWE-127).</Alternate_Terms>
			<Likelihood_of_Exploit>Medium</Likelihood_of_Exploit>
			<Weakness_Ordinality>Primary (Weakness exists independent of other weaknesses)</Weakness_Ordinality>
			<Causal_Nature>Explicit (This is an explicit weakness resulting from behavior of the developer)</Causal_Nature>
			<Common_Consequences>
				<Common_Consequence>Availability: Buffer underwrites will very likely result in the corruption of
					relevant memory, and perhaps instructions, leading to a crash.</Common_Consequence>
				<Common_Consequence>Access Control (memory and instruction processing): If the corrupted memory
					can be effectively controlled, it may be possible to execute arbitrary code. If the corrupted
					memory is data rather than instructions, the system will continue to function with improper
					changes, possibly in violation of an implicit or explicit policy. The consequences would only
					be limited by how the affected data is used, such as an adjacent memory location that is used
					to specify whether the user has special privileges.</Common_Consequence>
				<Common_Consequence>Other: When the consequence is arbitrary code execution, this can often be
					used to subvert any other security service.</Common_Consequence>
			</Common_Consequences>
			<Potential_Mitigations>
				<Mitigation>Requirements specification: The choice could be made to use a language that is not
					susceptible to these issues.</Mitigation>
				<Mitigation>Implementation: Sanity checks should be performed on all calculated values used as
					index or for pointer arithmetic.</Mitigation>
			</Potential_Mitigations>
			<Demonstrative_Example>
				<Example_Code>
					<PreText>The following is an example of code that may result in a buffer underwrite, if find()
						returns a negative value to indicate that ch is not found in srcBuf:</PreText>
					<Example_Block>
						<Example_Code_Block>
							<Code_Example_Language>C</Code_Example_Language>
							<Code_Block><![CDATA[int main() {
	]]><![CDATA[				  ...  
					  strncpy(destB]]><![CDATA[uf, &srcBuf[find(srcBuf, ch)], 1]]><![CDATA[024);
					  ...
					}]]></Code_Block>
						</Example_Code_Block>
					</Example_Block>
					<PostText>If the index to srcBuf is somehow under user control, this is an arbitrary
						write-what-where condition.</PostText>
				</Example_Code>
			</Demonstrative_Example>
			<Observed_Examples>
				<Observed_Example>
					<Observed_Example_Reference>CVE-2002-2227</Observed_Example_Reference>
					<Observed_Example_Description>Unchecked length of SSLv2 challenge value leads to buffer underflow.</Observed_Example_Description>
					<Observed_Example_Link>http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2002-2227</Observed_Example_Link>
				</Observed_Example>
				<Observed_Example>
					<Observed_Example_Reference>CVE-2007-4580</Observed_Example_Reference>
					<Observed_Example_Description>Buffer underflow from a small size value with a large buffer (length parameter
						inconsistency, CWE-130)</Observed_Example_Description>
					<Observed_Example_Link>http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2007-4580</Observed_Example_Link>
				</Observed_Example>
				<Observed_Example>
					<Observed_Example_Reference>CVE-2007-1584</Observed_Example_Reference>
					<Observed_Example_Description>Buffer underflow from an all-whitespace string, which causes a counter to be
						decremented before the buffer while looking for a non-whitespace character.</Observed_Example_Description>
					<Observed_Example_Link>http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2007-1584</Observed_Example_Link>
				</Observed_Example>
				<Observed_Example>
					<Observed_Example_Reference>CVE-2007-0886</Observed_Example_Reference>
					<Observed_Example_Description>Buffer underflow resultant from encoded data that triggers an integer overflow.</Observed_Example_Description>
					<Observed_Example_Link>http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2007-0886</Observed_Example_Link>
				</Observed_Example>
				<Observed_Example>
					<Observed_Example_Reference>CVE-2006-6171</Observed_Example_Reference>
					<Observed_Example_Description>Product sets an incorrect buffer size limit, leading to "off-by-two" buffer
						underflow.</Observed_Example_Description>
					<Observed_Example_Link>http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2006-6171</Observed_Example_Link>
				</Observed_Example>
				<Observed_Example>
					<Observed_Example_Reference>CVE-2006-4024</Observed_Example_Reference>
					<Observed_Example_Description>Negative value is used in a memcpy() operation, leading to buffer underflow.</Observed_Example_Description>
					<Observed_Example_Link>http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2006-4024</Observed_Example_Link>
				</Observed_Example>
				<Observed_Example>
					<Observed_Example_Reference>CVE-2004-2620</Observed_Example_Reference>
					<Observed_Example_Description>Buffer underflow due to mishandled special characters</Observed_Example_Description>
					<Observed_Example_Link>http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2004-2620</Observed_Example_Link>
				</Observed_Example>
			</Observed_Examples>
			<Context_Notes>This could be resultant from several errors, including a bad offset or an array index
				that decrements before the beginning of the buffer (see CWE-129).</Context_Notes>
			<Research_Gaps>Much attention has been paid to buffer overflows, but "underflows" sometimes exist in
				products that are relatively free of overflows, so it is likely that this variant has been
				under-studied.</Research_Gaps>
			<References>
				<Reference>
					<Reference_Title>Buffer UNDERFLOWS: What do you know about it?</Reference_Title>
					<Reference_Publication>Vuln-Dev Mailing List</Reference_Publication>
					<Reference_Date>2004-01-10</Reference_Date>
					<Reference_Link>http://seclists.org/vuln-dev/2004/Jan/0022.html</Reference_Link>
				</Reference>
			</References>
				<Relationships>
				<Relationship>
						<Relationship_Views>
							<Relationship_View_ID Ordinal="Primary">1000</Relationship_View_ID>
						</Relationship_Views>
						<Relationship_Type>Weakness</Relationship_Type>
					<Relationship_Nature>ChildOf</Relationship_Nature>
					<Relationship_Target_ID>119</Relationship_Target_ID>
				</Relationship>
				<Relationship>
						<Relationship_Views>
							<Relationship_View_ID>1000</Relationship_View_ID>
						</Relationship_Views>
						<Relationship_Type>Compound_Element</Relationship_Type>
					<Relationship_Nature>PeerOf</Relationship_Nature>
					<Relationship_Target_ID>120</Relationship_Target_ID>
				</Relationship>
				<Relationship>
						<Relationship_Views>
							<Relationship_View_ID>1000</Relationship_View_ID>
						</Relationship_Views>
						<Relationship_Type>Weakness</Relationship_Type>
					<Relationship_Nature>PeerOf</Relationship_Nature>
					<Relationship_Target_ID>129</Relationship_Target_ID>
				</Relationship>
				</Relationships>
			<Source_Taxonomy Source_Taxonomy_Name="PLOVER">
				<Original_Node_Name>UNDER - Boundary beginning violation ('buffer underflow'
				?)</Original_Node_Name>
			</Source_Taxonomy>
			<Source_Taxonomy Source_Taxonomy_Name="CLASP">
				<Original_Node_Name>Buffer underwrite</Original_Node_Name>
			</Source_Taxonomy>
			<Applicable_Platforms>
				<Platform>C</Platform>
				<Platform>C++</Platform>
			</Applicable_Platforms>
			<Time_of_Introduction>Implementation</Time_of_Introduction>
		</Common_Attributes>
	</Weakness>
                    <Weakness Weakness_ID="125" Weakness_Name="Out-of-bounds Read" Weakness_Abstraction="Base" Weakness_Status="Draft">
		<Common_Attributes>
			<Description>
				<Description_Summary>The software reads data past the end, or before the beginning, of the intended buffer.</Description_Summary>
			</Description>
			<Weakness_Ordinality>Primary (Weakness exists independent of other weaknesses)</Weakness_Ordinality>
			<Causal_Nature>Explicit (This is an explicit weakness resulting from behavior of the developer)</Causal_Nature>
			<Observed_Examples>
				<Observed_Example>
					<Observed_Example_Reference>CVE-2004-0112</Observed_Example_Reference>
					<Observed_Example_Description>out-of-bounds read due to improper length check</Observed_Example_Description>
				</Observed_Example>
				<Observed_Example>
					<Observed_Example_Reference>CVE-2004-0183</Observed_Example_Reference>
					<Observed_Example_Description>packet with large number of specified elements cause out-of-bounds
					read.</Observed_Example_Description>
				</Observed_Example>
				<Observed_Example>
					<Observed_Example_Reference>CVE-2004-0221</Observed_Example_Reference>
					<Observed_Example_Description>packet with large number of specified elements cause out-of-bounds
					read.</Observed_Example_Description>
				</Observed_Example>
				<Observed_Example>
					<Observed_Example_Reference>CVE-2004-0184</Observed_Example_Reference>
					<Observed_Example_Description>out-of-bounds read, resultant from integer underflow</Observed_Example_Description>
				</Observed_Example>
				<Observed_Example>
					<Observed_Example_Reference>CVE-2004-1940</Observed_Example_Reference>
					<Observed_Example_Description>large length value causes out-of-bounds read</Observed_Example_Description>
				</Observed_Example>
				<Observed_Example>
					<Observed_Example_Reference>CVE-2004-0421</Observed_Example_Reference>
					<Observed_Example_Description>malformed image causes out-of-bounds read</Observed_Example_Description>
				</Observed_Example>
			</Observed_Examples>
			<Research_Gaps>Under-studied and under-reported. Most issues are probably labeled as buffer overflows.</Research_Gaps>
				<Relationships>
				<Relationship>
						<Relationship_Views>
							<Relationship_View_ID Ordinal="Primary">1000</Relationship_View_ID>
						</Relationship_Views>
						<Relationship_Type>Weakness</Relationship_Type>
					<Relationship_Nature>ChildOf</Relationship_Nature>
					<Relationship_Target_ID>119</Relationship_Target_ID>
				</Relationship>
				</Relationships>
			<Source_Taxonomy Source_Taxonomy_Name="PLOVER">
				<Original_Node_Name>Out-of-bounds Read</Original_Node_Name>
			</Source_Taxonomy>
			<Applicable_Platforms>
				<Platform>C</Platform>
				<Platform>C++</Platform>
			</Applicable_Platforms>
			<Time_of_Introduction>Implementation</Time_of_Introduction>
		</Common_Attributes>
	</Weakness>
                    <Weakness Weakness_ID="126" Weakness_Name="Buffer Over-read" Weakness_Abstraction="Variant" Weakness_Status="Draft">
		<Common_Attributes>
			<Description>
				<Description_Summary>The software reads data past the end of the intended buffer.</Description_Summary>
			</Description>
			<Weakness_Ordinality>Primary (Weakness exists independent of other weaknesses)</Weakness_Ordinality>
			<Causal_Nature>Explicit (This is an explicit weakness resulting from behavior of the developer)</Causal_Nature>
				<Relationships>
				<Relationship>
						<Relationship_Views>
							<Relationship_View_ID Ordinal="Primary">1000</Relationship_View_ID>
						</Relationship_Views>
						<Relationship_Type>Weakness</Relationship_Type>
					<Relationship_Nature>ChildOf</Relationship_Nature>
					<Relationship_Target_ID>125</Relationship_Target_ID>
				</Relationship>
				</Relationships>
			<Source_Taxonomy Source_Taxonomy_Name="PLOVER">
				<Original_Node_Name>Buffer over-read</Original_Node_Name>
			</Source_Taxonomy>
			<Applicable_Platforms>
				<Platform>C</Platform>
				<Platform>C++</Platform>
			</Applicable_Platforms>
			<Time_of_Introduction>Implementation</Time_of_Introduction>
		</Common_Attributes>
	</Weakness>
                    <Weakness Weakness_ID="127" Weakness_Name="Buffer Under-read" Weakness_Abstraction="Variant" Weakness_Status="Draft">
		<Common_Attributes>
			<Description>
				<Description_Summary>The software reads data before the start of the intended buffer.</Description_Summary>
			</Description>
			<Weakness_Ordinality>Primary (Weakness exists independent of other weaknesses)</Weakness_Ordinality>
			<Causal_Nature>Explicit (This is an explicit weakness resulting from behavior of the developer)</Causal_Nature>
			<Research_Gaps>Under-studied.</Research_Gaps>
				<Relationships>
				<Relationship>
						<Relationship_Views>
							<Relationship_View_ID Ordinal="Primary">1000</Relationship_View_ID>
						</Relationship_Views>
						<Relationship_Type>Weakness</Relationship_Type>
					<Relationship_Nature>ChildOf</Relationship_Nature>
					<Relationship_Target_ID>125</Relationship_Target_ID>
				</Relationship>
				</Relationships>
			<Source_Taxonomy Source_Taxonomy_Name="PLOVER">
				<Original_Node_Name>Buffer under-read</Original_Node_Name>
			</Source_Taxonomy>
			<Applicable_Platforms>
				<Platform>C</Platform>
				<Platform>C++</Platform>
			</Applicable_Platforms>
			<Time_of_Introduction>Implementation</Time_of_Introduction>
		</Common_Attributes>
	</Weakness>
                    <Weakness Weakness_ID="129" Weakness_Name="Unchecked Array Indexing" Weakness_Abstraction="Base" Weakness_Status="Draft">
		<Common_Attributes>
			<Description>
				<Description_Summary>Unchecked array indexing occurs when an unchecked value is used as an index
				into a buffer.</Description_Summary>
			</Description>
			<Alternate_Terms>"out-of-bounds array index" or "index-out-of-range" or "array index
				underflow"</Alternate_Terms>
			<Likelihood_of_Exploit>Medium</Likelihood_of_Exploit>
			<Weakness_Ordinality>Resultant (Weakness is typically related to the presence of some other weaknesses)</Weakness_Ordinality>
			<Causal_Nature>Explicit (This is an explicit weakness resulting from behavior of the developer)</Causal_Nature>
			<Affected_Resource>Memory</Affected_Resource>
			<Common_Consequences>
				<Common_Consequence>Availability: Unchecked array indexing will very likely result in
					the corruption of relevant memory and perhaps instructions, leading to a crash, if
					the values are outside of the valid memory area</Common_Consequence>
				<Common_Consequence>Integrity: If the memory corrupted is data, rather than
					instructions, the system will continue to function with improper values.</Common_Consequence>
				<Common_Consequence>Access Control: If the memory corrupted memory can be effectively
					controlled, it may be possible to execute arbitrary code, as with a standard buffer
					overflow.</Common_Consequence>
			</Common_Consequences>
			<Potential_Mitigations>
				<Mitigation>Requirements specification: The choice could be made to use a language that
					is not susceptible to these issues.</Mitigation>
				<Mitigation>Implementation: Include sanity checks to ensure the validity of any values
					used as index variables. In loops, use greater-than-or-equal-to, or
					less-than-or-equal-to, as opposed to simply greater-than, or less-than compare
					statements.</Mitigation>
			</Potential_Mitigations>
			<Observed_Examples>
				<Observed_Example>
					<Observed_Example_Reference>CVE-2005-0369</Observed_Example_Reference>
					<Observed_Example_Description>large ID in packet used as array index</Observed_Example_Description>
				</Observed_Example>
				<Observed_Example>
					<Observed_Example_Reference>CVE-2001-1009</Observed_Example_Reference>
					<Observed_Example_Description>negative array index as argument to POP LIST command</Observed_Example_Description>
				</Observed_Example>
				<Observed_Example>
					<Observed_Example_Reference>CVE-2003-0721</Observed_Example_Reference>
					<Observed_Example_Description>Integer signedness error leads to negative array index</Observed_Example_Description>
				</Observed_Example>
				<Observed_Example>
					<Observed_Example_Reference>CVE-2004-1189</Observed_Example_Reference>
					<Observed_Example_Description>product does not properly track a count and a maximum number, which can
						lead to resultant array index overflow.</Observed_Example_Description>
				</Observed_Example>
			</Observed_Examples>
			<Context_Notes>A single fault could allow both an overflow and underflow of the array index.</Context_Notes>
			<Context_Notes>An index overflow exploit might use buffer overflow techniques, but this can
				often be exploited without having to provide "large inputs."</Context_Notes>
			<Context_Notes>Array index overflows can also trigger out-of-bounds read operations, or
				operations on the wrong objects; i.e., "buffer overflows" are not always the result.</Context_Notes>
			<Context_Notes>Unchecked array indexing, depending on its instantiation, can be responsible
				for any number of related issues. Most prominent of these possible flaws is the buffer
				overflow condition. Due to this fact, consequences range from denial of service, and
				data corruption, to full blown arbitrary code execution. The most common condition
				situation leading to unchecked array indexing is the use of loop index variables as
				buffer indexes. If the end condition for the loop is subject to a flaw, the index can
				grow or shrink unbounded, therefore causing a buffer overflow or underflow. Another
				common situation leading to this condition is the use of a function's return value, or
				the resulting value of a calculation directly as an index in to a buffer.</Context_Notes>
				<Relationships>
				<Relationship>
						<Relationship_Views>
							<Relationship_View_ID Ordinal="Primary">1000</Relationship_View_ID>
						</Relationship_Views>
						<Relationship_Type>Weakness</Relationship_Type>
					<Relationship_Nature>ChildOf</Relationship_Nature>
					<Relationship_Target_ID>119</Relationship_Target_ID>
				</Relationship>
				<Relationship>
						<Relationship_Views>
							<Relationship_View_ID Ordinal="Primary">631</Relationship_View_ID>
						</Relationship_Views>
						<Relationship_Type>Category</Relationship_Type>
					<Relationship_Nature>ChildOf</Relationship_Nature>
					<Relationship_Target_ID>633</Relationship_Target_ID>
				</Relationship>
				</Relationships>
			<Source_Taxonomy Source_Taxonomy_Name="CLASP">
				<Original_Node_Name>Unchecked array indexing</Original_Node_Name>
			</Source_Taxonomy>
			<Source_Taxonomy Source_Taxonomy_Name="PLOVER">
				<Original_Node_Name>INDEX - Array index overflow</Original_Node_Name>
			</Source_Taxonomy>
			<Applicable_Platforms>
				<Platform>C</Platform>
				<Platform>C++</Platform>
			</Applicable_Platforms>
			<Time_of_Introduction>Implementation</Time_of_Introduction>
		</Common_Attributes>
	</Weakness>
                    <Weakness Weakness_ID="131" Weakness_Name="Incorrect Calculation of Buffer Size" Weakness_Abstraction="Class" Weakness_Status="Draft">
		<Common_Attributes>
			<Description>
				<Description_Summary>The software does not correctly
					calculate the size to be used when allocating
					a buffer, which could lead to a buffer overflow.</Description_Summary>
			</Description>
			<Observed_Examples>
				<Observed_Example>
					<Observed_Example_Reference>CVE-2004-1363</Observed_Example_Reference>
					<Observed_Example_Description>substitution overflow: buffer overflow using environment variables that are expanded
						after the length check is performed</Observed_Example_Description>
				</Observed_Example>
				<Observed_Example>
					<Observed_Example_Reference>CVE-2004-0747</Observed_Example_Reference>
					<Observed_Example_Description>substitution overflow: buffer overflow using expansion of environment
					variables</Observed_Example_Description>
				</Observed_Example>
				<Observed_Example>
					<Observed_Example_Reference>CVE-2005-2103</Observed_Example_Reference>
					<Observed_Example_Description>substitution overflow: buffer overflow using a large number of substitution
					strings</Observed_Example_Description>
				</Observed_Example>
				<Observed_Example>
					<Observed_Example_Reference>CVE-2005-3120</Observed_Example_Reference>
					<Observed_Example_Description>transformation overflow: product adds extra escape characters to incoming data, but
						does not account for them in the buffer length</Observed_Example_Description>
				</Observed_Example>
				<Observed_Example>
					<Observed_Example_Reference>CVE-2003-0899</Observed_Example_Reference>
					<Observed_Example_Description>transformation overflow: buffer overflow when expanding "&gt;" to "&amp;gt;",
						etc.</Observed_Example_Description>
				</Observed_Example>
				<Observed_Example>
					<Observed_Example_Reference>CVE-2001-0334</Observed_Example_Reference>
					<Observed_Example_Description>expansion overflow: buffer overflow using wildcards</Observed_Example_Description>
				</Observed_Example>
				<Observed_Example>
					<Observed_Example_Reference>CVE-2001-0248</Observed_Example_Reference>
					<Observed_Example_Description>expansion overflow: long pathname + glob = overflow</Observed_Example_Description>
				</Observed_Example>
				<Observed_Example>
					<Observed_Example_Reference>CVE-2001-0249</Observed_Example_Reference>
					<Observed_Example_Description>expansion overflow: long pathname + glob = overflow</Observed_Example_Description>
				</Observed_Example>
				<Observed_Example>
					<Observed_Example_Reference>CVE-2002-0184</Observed_Example_Reference>
					<Observed_Example_Description>special characters in argument are not properly expanded</Observed_Example_Description>
				</Observed_Example>
				<Observed_Example>
					<Observed_Example_Reference>CVE-2004-0434</Observed_Example_Reference>
					<Observed_Example_Description>small length value leads to heap overflow</Observed_Example_Description>
				</Observed_Example>
				<Observed_Example>
					<Observed_Example_Reference>CVE-2002-1347</Observed_Example_Reference>
					<Observed_Example_Description>multiple variants</Observed_Example_Description>
				</Observed_Example>
				<Observed_Example>
					<Observed_Example_Reference>CVE-2005-0490</Observed_Example_Reference>
					<Observed_Example_Description>needs closer investigation, but probably expansion-based</Observed_Example_Description>
				</Observed_Example>
				<Observed_Example>
					<Observed_Example_Reference>CVE-2004-0940</Observed_Example_Reference>
					<Observed_Example_Description>needs closer investigation, but probably expansion-based</Observed_Example_Description>
				</Observed_Example>
			</Observed_Examples>
			<Context_Notes>This is a broad category. Some examples include: (1) simple math errors, (2)
				incorrectly updating parallel counters, (3) not accounting for size differences when
				"transforming" one input to another format (e.g. URL canonicalization or other transformation that
				can generate a result that's larger than the original input, i.e. "expansion").</Context_Notes>
			<Context_Notes>This level of detail is rarely available in public reports, so it is difficult to find
				good examples.</Context_Notes>
				<Relationships>
				<Relationship>
						<Relationship_Views>
							<Relationship_View_ID Ordinal="Primary">1000</Relationship_View_ID>
						</Relationship_Views>
						<Relationship_Type>Weakness</Relationship_Type>
					<Relationship_Nature>ChildOf</Relationship_Nature>
					<Relationship_Target_ID>119</Relationship_Target_ID>
				</Relationship>
				</Relationships>
			<Source_Taxonomy Source_Taxonomy_Name="PLOVER">
				<Original_Node_Name>Other length calculation error</Original_Node_Name>
			</Source_Taxonomy>
			<Applicable_Platforms>
				<Platform>C</Platform>
				<Platform>C++</Platform>
			</Applicable_Platforms>
			<Related_Attack_Patterns>
				<Related_Attack_Pattern>
					<CAPEC_ID>47<!--Buffer Overflow via Parameter Expansion--></CAPEC_ID>
				</Related_Attack_Pattern>
			</Related_Attack_Patterns>
		</Common_Attributes>
	</Weakness>
                    <Weakness Weakness_ID="132" Weakness_Name="Miscalculated Null Termination" Weakness_Abstraction="Base" Weakness_Status="Draft">
		<Common_Attributes>
			<Description>
				<Description_Summary>Miscalculated null termination occurs when the placement of a null character at the end
				of a buffer of characters (or string) is misplaced or omitted.</Description_Summary>
			</Description>
			<Likelihood_of_Exploit>Medium</Likelihood_of_Exploit>
			<Weakness_Ordinality>Primary (Weakness exists independent of other weaknesses)</Weakness_Ordinality>
			<Causal_Nature>Explicit (This is an explicit weakness resulting from behavior of the developer)</Causal_Nature>
			<Common_Consequences>
				<Common_Consequence>Confidentiality: Information disclosure may occur if strings with misplaced or
					omitted null characters are printed.</Common_Consequence>
				<Common_Consequence>Availability: A randomly placed null character may put the system into an
					undefined state, and therefore make it prone to crashing.</Common_Consequence>
				<Common_Consequence>Integrity: A misplaced null character may corrupt other data in memory</Common_Consequence>
				<Common_Consequence>Access Control: Should the null character corrupt the process flow, or effect
					a flag controlling access, it may lead to logical errors which allow for the execution of
					arbitrary code.</Common_Consequence>
			</Common_Consequences>
			<Potential_Mitigations>
				<Mitigation>Requirements specification: The choice could be made to use a language that is not
					susceptible to these issues.</Mitigation>
				<Mitigation>Implementation: Ensure that all string functions used are understood fully as to how
					they append null characters. Also, be wary of off-by-one errors when appending nulls to the
					end of strings.</Mitigation>
			</Potential_Mitigations>
			<Demonstrative_Example>
				<Example_Code>
					<PreText>While the following example is not exploitable, it provides a good example of how
						nulls can be omitted or misplaced, even when "safe" functions are used:</PreText>
					<Example_Block>
						<Example_Code_Block>
							<Code_Example_Language>C</Code_Example_Language>
							<Code_Block><![CDATA[#include <stdio.h>
					#in]]><![CDATA[clude <string.h>
					
					int ]]><![CDATA[main() {   
					  char longStri]]><![CDATA[ng[] = "String signifying nothin]]><![CDATA[g";
					  char shortString[16];]]><![CDATA[    
					
					  strncpy(shortS]]><![CDATA[tring, longString, 16);    
				]]><![CDATA[	  printf("The last character in]]><![CDATA[ shortString is: %c %1$x\n", sho]]><![CDATA[rtString[15]);    
					  return]]><![CDATA[ (0);
					}]]></Code_Block>
						</Example_Code_Block>
					</Example_Block>
					<PostText>The above code gives the following output: The last character in shortString is: l
						6c So, the shortString array does not end in a NULL character, even though the "safe"
						string function strncpy() was used.</PostText>
				</Example_Code>
			</Demonstrative_Example>
			<Context_Notes>Miscalculated null termination is a common issue, and often difficult to detect. The
				most common symptoms occur infrequently (in the case of problems resulting from "safe" string
				functions), or in odd ways characterized by data corruption (when caused by off-by-one errors).
				The case of an omitted null character is the most dangerous of the possible issues. This will
				almost certainly result in information disclosure, and possibly a buffer overflow condition, which
				may be exploited to execute arbitrary code. As for misplaced null characters, the biggest issue is
				a subset of buffer overflow, and write-what-where conditions, where data corruption occurs from
				the writing of a null character over valid data, or even instructions. These logic issues may
				result in any number of security flaws.</Context_Notes>
				<Relationships>
				<Relationship>
						<Relationship_Views>
							<Relationship_View_ID Ordinal="Primary">1000</Relationship_View_ID>
						</Relationship_Views>
						<Relationship_Type>Weakness</Relationship_Type>
					<Relationship_Nature>ChildOf</Relationship_Nature>
					<Relationship_Target_ID>119</Relationship_Target_ID>
				</Relationship>
				<Relationship>
					<Relationship_Views>
						<Relationship_View_ID>1000</Relationship_View_ID>
					</Relationship_Views>
					<Relationship_Type>Weakness</Relationship_Type>
					<Relationship_Nature>ChildOf</Relationship_Nature>
					<Relationship_Target_ID>682</Relationship_Target_ID>
				</Relationship>
				<Relationship>
						<Relationship_Views>
							<Relationship_View_ID>1000</Relationship_View_ID>
						</Relationship_Views>
						<Relationship_Type>Compound_Element</Relationship_Type>
					<Relationship_Nature>PeerOf</Relationship_Nature>
					<Relationship_Target_ID>120</Relationship_Target_ID>
				</Relationship>
				<Relationship>
						<Relationship_Views>
							<Relationship_View_ID>1000</Relationship_View_ID>
						</Relationship_Views>
						<Relationship_Type>Weakness</Relationship_Type>
					<Relationship_Nature>PeerOf</Relationship_Nature>
					<Relationship_Target_ID>123</Relationship_Target_ID>
				</Relationship>
				</Relationships>
			<Source_Taxonomy Source_Taxonomy_Name="CLASP">
				<Original_Node_Name>Miscalculated null termination</Original_Node_Name>
			</Source_Taxonomy>
			<Applicable_Platforms>
				<Platform>C</Platform>
				<Platform>C++</Platform>
			</Applicable_Platforms>
		</Common_Attributes>
	</Weakness>
                    <Weakness Weakness_ID="135" Weakness_Name="Incorrect Calculation of Multi-Byte String Length" Weakness_Abstraction="Base" Weakness_Status="Draft">
		<Common_Attributes>
			<Description>
				<Description_Summary>The software does not properly calculate the length of strings that can contain wide or multi-byte characters.</Description_Summary>
			</Description>
			<Demonstrative_Example>
				<Example_Code>
					<PreText>The following example would be exploitable if any of the commented incorrect malloc
						calls were used.</PreText>
					<Example_Block>
						<Example_Code_Block>
							<Code_Example_Language>C</Code_Example_Language>
							<Code_Block><![CDATA[#include <stdio.h>
					#inc]]><![CDATA[lude <strings.h>
					#include <]]><![CDATA[wchar.h>
					
					int main() {]]><![CDATA[   
					  wchar_t wideString[] ]]><![CDATA[= L"The spazzy orange tiger jump]]><![CDATA[ed " \ 
											  "over the t]]><![CDATA[awny jaguar.";    
					  wchar_]]><![CDATA[t *newString;    
					
					  p]]><![CDATA[rintf("Strlen() output: %d\nWcsl]]><![CDATA[en() output: %d\n", 
					  strl]]><![CDATA[en(wideString), wcslen(wideStrin]]><![CDATA[g));    
					
					  /* Very wr]]><![CDATA[ong for obvious reasons //    
	]]><![CDATA[				  newString = (wchar_t *) ma]]><![CDATA[lloc(strlen(wideString));    
		]]><![CDATA[			  */    
					
					  /* Wron]]><![CDATA[g because wide characters aren't]]><![CDATA[ 1 byte long! //    
					  newS]]><![CDATA[tring = (wchar_t *) malloc(wcsle]]><![CDATA[n(wideString));    
					  */   ]]><![CDATA[ 
					
					  /* correct! */   ]]><![CDATA[ 
					  newString = (wchar_t *)]]><![CDATA[ malloc(wcslen(wideString) * siz]]><![CDATA[eof(wchar_t));    
					
					  ]]><![CDATA[/* ... */
					}]]></Code_Block>
						</Example_Code_Block>
					</Example_Block>
					<PostText>The output from the printf() statement would be: Strlen() output: 0 Wcslen() output:
						53</PostText>
				</Example_Code>
			</Demonstrative_Example>
			<Context_Notes>There are several ways in which improper string length checking may result in an
				exploitable condition. All of these, however, involve the introduction of buffer overflow
				conditions in order to reach an exploitable state. The first of these issues takes place when the
				output of a wide or multi-byte character string, string-length function is used as a size for the
				allocation of memory. While this will result in an output of the number of characters in the
				string, note that the characters are most likely not a single byte, as they are with standard
				character strings. So, using the size returned as the size sent to new or malloc and copying the
				string to this newly allocated memory will result in a buffer overflow. Another common way these
				strings are misused involves the mixing of standard string and wide or multi-byte string functions
				on a single string. Invariably, this mismatched information will result in the creation of a
				possibly exploitable buffer overflow condition. Again, if a language subject to these flaws must
				be used, the most effective mitigation technique is to pay careful attention to the code at
				implementation time and ensure that these flaws do not occur.</Context_Notes>
				<Relationships>
				<Relationship>
					<Relationship_Views>
						<Relationship_View_ID Ordinal="Primary">1000</Relationship_View_ID>
					</Relationship_Views>
					<Relationship_Type>Weakness</Relationship_Type>
					<Relationship_Nature>ChildOf</Relationship_Nature>
					<Relationship_Target_ID>682</Relationship_Target_ID>
				</Relationship>
				<Relationship>
						<Relationship_Views>
							<Relationship_View_ID>1000</Relationship_View_ID>
						</Relationship_Views>
						<Relationship_Type>Category</Relationship_Type>
					<Relationship_Nature>ChildOf</Relationship_Nature>
					<Relationship_Target_ID>133</Relationship_Target_ID>
				</Relationship>
				</Relationships>
			<Source_Taxonomy Source_Taxonomy_Name="CLASP">
				<Original_Node_Name>Improper string length checking</Original_Node_Name>
			</Source_Taxonomy>
			<Applicable_Platforms>
				<Platform>C</Platform>
				<Platform>C++</Platform>
			</Applicable_Platforms>
		</Common_Attributes>
	</Weakness>
                    <Weakness Weakness_ID="170" Weakness_Name="Improper Null Termination" Weakness_Abstraction="Base" Weakness_Status="Incomplete">
		<Common_Attributes>
			<Description>
				<Description_Summary>The software does not properly terminate a string or array with a null character or
				equivalent terminator. Null termination errors frequently occur in two different ways. An
				off-by-one error could cause a null to be written out of bounds, leading to an overflow. Or, a
				program could use a strncpy() function call incorrectly, which prevents a null terminator from
				being added at all. Other scenarios are possible.</Description_Summary>
			</Description>
			<Likelihood_of_Exploit>High</Likelihood_of_Exploit>
			<Potential_Mitigations>
				<Mitigation>If performance constraints permit, special code can be added that validates
					null-termination of string buffers, this is a rather naïve and error-prone solution.</Mitigation>
				<Mitigation>Switch to bounded string manipulation functions. Inspect buffer lengths involved in
					the buffer overrun trace reported with the defect.</Mitigation>
				<Mitigation>Add code that fills buffers with nulls (however, the length of buffers still needs to
					be inspected, to ensure that the non null-terminated string is not written at the physical end
					of the buffer).</Mitigation>
			</Potential_Mitigations>
			<Demonstrative_Example>
				<Example_Code>
					<PreText>Example 1: The following code reads from cfgfile and copies the input into inputbuf
						using strcpy(). The code mistakenly assumes that inputbuf will always contain a NULL
						terminator.</PreText>
					<Example_Block>
						<Example_Code_Block>
							<Code_Block><![CDATA[#define MAXLEN 1024 
				]]><![CDATA[	...
					char *pathbuf[MAXLEN];]]><![CDATA[ 
					...
					read(cfgfile,inp]]><![CDATA[utbuf,MAXLEN); //does not null t]]><![CDATA[erminate 
					strcpy(pathbuf,in]]><![CDATA[put_buf); //requires null termin]]><![CDATA[ated input 
					...]]></Code_Block>
						</Example_Code_Block>
					</Example_Block>
					<PostText>The code in Example 1 will behave correctly if the data read from cfgfile is null
						terminated on disk as expected. But if an attacker is able to modify this input so that it
						does not contain the expected NULL character, the call to strcpy() will continue copying
						from memory until it encounters an arbitrary NULL character. This will likely overflow the
						destination buffer and, if the attacker can control the contents of memory immediately
						following inputbuf, can leave the application susceptible to a buffer overflow
					attack.</PostText>
				</Example_Code>
				<Example_Code>
					<PreText>Example 2: In the following code, readlink() expands the name of a symbolic link
						stored in the buffer path so that the buffer filename contains the absolute path of the
						file referenced by the symbolic link. The length of the resulting value is then calculated
						using strlen().</PreText>
					<Example_Block>
						<Example_Code_Block>
							<Code_Block><![CDATA[...
					char buf[MAXPATH];
		]]><![CDATA[			...
					readlink(path, buf, ]]><![CDATA[MAXPATH);
					int length = strl]]><![CDATA[en(filename);
					...]]></Code_Block>
						</Example_Code_Block>
					</Example_Block>
					<PostText>The code in Example 2 will not behave correctly because the value read into buf by
						readlink() will not be null terminated. In testing, vulnerabilities like this one might
						not be caught because the unused contents of buf and the memory immediately following it
						may be NULL, thereby causing strlen() to appear as if it is behaving correctly. However,
						in the wild strlen() will continue traversing memory until it encounters an arbitrary NULL
						character on the stack, which results in a value of length that is much larger than the
						size of buf and may cause a buffer overflow in subsequent uses of this value. Buffer
						overflows aside, whenever a single call to readlink() returns the same value that has been
						passed to its third argument, it is impossible to know whether the name is precisely that
						many bytes long, or whether readlink() has truncated the name to avoid overrunning the
						buffer. Traditionally, strings are represented as a region of memory containing data
						terminated with a NULL character. Older string-handling methods frequently rely on this
						NULL character to determine the length of the string. If a buffer that does not contain a
						NULL terminator is passed to one of these functions, the function will read past the end
						of the buffer. Malicious users typically exploit this type of vulnerability by injecting
						data with unexpected size or content into the application. They may provide the malicious
						input either directly as input to the program or indirectly by modifying application
						resources, such as configuration files. In the event that an attacker causes the
						application to read beyond the bounds of a buffer, the attacker may be able use a
						resulting buffer overflow to inject and execute arbitrary code on the system. </PostText>
				</Example_Code>
			</Demonstrative_Example>
			<Observed_Examples>
				<Observed_Example>
					<Observed_Example_Reference>CVE-2000-0312</Observed_Example_Reference>
					<Observed_Example_Description>Attacker does not null-terminate argv[] when invoking another program.</Observed_Example_Description>
				</Observed_Example>
				<Observed_Example>
					<Observed_Example_Reference>CVE-2003-0777</Observed_Example_Reference>
					<Observed_Example_Description>Interrupted step causes resultant lack of null termination.</Observed_Example_Description>
				</Observed_Example>
				<Observed_Example>
					<Observed_Example_Reference>CVE-2004-1072</Observed_Example_Reference>
					<Observed_Example_Description>Fault causes resultant lack of null termination, leading to buffer expansion.</Observed_Example_Description>
				</Observed_Example>
				<Observed_Example>
					<Observed_Example_Reference>CVE-2001-1389</Observed_Example_Reference>
					<Observed_Example_Description>Multiple vulnerabilities related to improper null termination.</Observed_Example_Description>
				</Observed_Example>
				<Observed_Example>
					<Observed_Example_Reference>CVE-2003-0143</Observed_Example_Reference>
					<Observed_Example_Description>Product does not null terminate a message buffer after snprintf-like call, leading to
						overflow.</Observed_Example_Description>
				</Observed_Example>
			</Observed_Examples>
			<Context_Notes>Conceptually, this does not just apply to the C language; any language or
				representation that involves a terminator could have this sort of problem.</Context_Notes>
			<Context_Notes>Factors: this is usually resultant from other weaknesses such as off-by-one errors, but
				it can be primary to boundary condition violations such as buffer overflows. In buffer overflows,
				it can act as an expander for assumed-immutable data.</Context_Notes>
			<Context_Notes>Overlaps missing input terminator.</Context_Notes>
				<Relationships>
				<Relationship>
						<Relationship_Views>
							<Relationship_View_ID Ordinal="Primary">1000</Relationship_View_ID>
						</Relationship_Views>
						<Relationship_Type>Category</Relationship_Type>
					<Relationship_Nature>ChildOf</Relationship_Nature>
					<Relationship_Target_ID>169</Relationship_Target_ID>
				</Relationship>
				<Relationship>
						<Relationship_Views>
							<Relationship_View_ID>1000</Relationship_View_ID>
						</Relationship_Views>
						<Relationship_Type>Compound_Element</Relationship_Type>
					<Relationship_Nature>CanPrecede</Relationship_Nature>
					<Relationship_Target_ID>120</Relationship_Target_ID>
				</Relationship>
				<Relationship>
						<Relationship_Views>
							<Relationship_View_ID>1000</Relationship_View_ID>
						</Relationship_Views>
						<Relationship_Type>Weakness</Relationship_Type>
					<Relationship_Nature>CanAlsoBe</Relationship_Nature>
					<Relationship_Target_ID>147</Relationship_Target_ID>
				</Relationship>
				<Relationship>
						<Relationship_Views>
							<Relationship_View_ID Ordinal="Primary">630</Relationship_View_ID>
						</Relationship_Views>
						<Relationship_Type>View</Relationship_Type>
					<Relationship_Nature>ChildOf</Relationship_Nature>
					<Relationship_Target_ID>630</Relationship_Target_ID>
				</Relationship>
				</Relationships>
			<Source_Taxonomy Source_Taxonomy_Name="PLOVER">
				<Original_Node_Name>Improper Null Termination</Original_Node_Name>
			</Source_Taxonomy>
			<Source_Taxonomy Source_Taxonomy_Name="7 Pernicious Kingdoms">
				<Original_Node_Name>String Termination Error</Original_Node_Name>
			</Source_Taxonomy>
			<Applicable_Platforms>
				<Platform>C</Platform>
				<Platform>C++</Platform>
			</Applicable_Platforms>
			<White_Box_Definition>
	A weakness where the code path has:
	1.        end statement that passes a data item to a null-terminated string function
	2.        start statement that removes the null-terminator from the data item 
	
	Where “removes” is defined through the following scenarios:
	1.        data item never ended with null-terminator 
	2.        null-terminator is re-written
	3.        null-terminator was purposely removed from data item
			</White_Box_Definition>
		</Common_Attributes>
	</Weakness>
                    <Weakness Weakness_ID="188" Weakness_Name="Reliance on Data/Memory Layout" Weakness_Abstraction="Base" Weakness_Status="Draft">
		<Common_Attributes>
			<Description>
				<Description_Summary>The software makes invalid assumptions about how protocol data or memory is organized at a lower level, resulting in unintended program behavior.</Description_Summary>
			</Description>
			<Likelihood_of_Exploit>Low</Likelihood_of_Exploit>
			<Common_Consequences>
				<Common_Consequence>Access control (including confidentiality and integrity): Can result in
					unintended modifications or information leaks of data.</Common_Consequence>
			</Common_Consequences>
			<Potential_Mitigations>
				<Mitigation>Design and Implementation: In flat address space situations, never allow computing
					memory addresses as offsets from another memory address.</Mitigation>
				<Mitigation>Design: Fully specify protocol layout unambiguously, providing a structured grammar
					(e.g., a compilable yacc grammar).</Mitigation>
				<Mitigation>Testing: Test that the implementation properly handles each case in the protocol
					grammar.</Mitigation>
			</Potential_Mitigations>
			<Demonstrative_Example>
				<Example_Code>
					<Example_Block>
						<Example_Code_Block>
							<Code_Example_Language>C</Code_Example_Language>
							<Code_Block><![CDATA[v]]><![CDATA[oid example() { 
					  char a; ]]><![CDATA[char b; *(&a + 1) = 0; 
					}]]></Code_Block>
						</Example_Code_Block>
					</Example_Block>
					<PostText>Here, b may not be one byte past a. It may be one byte in front of a. Or, they may
						have three bytes between them because they get aligned to 32-bit boundaries. </PostText>
				</Example_Code>
			</Demonstrative_Example>
			<Context_Notes>When changing platforms or protocol versions, data may move in unintended ways. For
				example, some architectures may place local variables a and b right next to each other with a on
				top; some may place them next to each other with b on top; and others may add some padding to
				each. This ensured that each variable is aligned to a proper word size. In protocol
				implementations, it is common to offset relative to another field to pick out a specific piece of
				data. Exceptional conditions -- often involving new protocol versions -- may add corner cases that
				lead to the data layout changing in an unusual way. The result can be that an implementation
				accesses a particular part of a packet, treating data of one type as data of another type. </Context_Notes>
				<Relationships>
				<Relationship>
						<Relationship_Views>
							<Relationship_View_ID Ordinal="Primary">1000</Relationship_View_ID>
						</Relationship_Views>
						<Relationship_Type>Category</Relationship_Type>
					<Relationship_Nature>ChildOf</Relationship_Nature>
					<Relationship_Target_ID>137</Relationship_Target_ID>
				</Relationship>
				</Relationships>
			<Source_Taxonomy Source_Taxonomy_Name="CLASP">
				<Original_Node_Name>Reliance on data layout</Original_Node_Name>
			</Source_Taxonomy>
			<Applicable_Platforms>
				<Platform>C</Platform>
				<Platform>C++</Platform>
			</Applicable_Platforms>
		</Common_Attributes>
	</Weakness>
                    <Weakness Weakness_ID="191" Weakness_Name="Integer Underflow (Wrap or Wraparound)" Weakness_Abstraction="Base" Weakness_Status="Draft">
		<Common_Attributes>
			<Description>
				<Description_Summary>The product subtracts one value
				from another, such that the result is less than the
				minimum allowable integer value, which produces a value that is not equal to the correct result. This can
				happen in signed and unsigned cases.</Description_Summary>
			</Description>
			<Alternate_Terms>"Integer underflow" is sometimes used to identify signedness errors in which an
				originally positive number becomes negative as a result of subtraction. However, there are cases
				of bad subtraction in which unsigned integers are involved, so it's not always a signedness issue.</Alternate_Terms>
			<Alternate_Terms>"Integer underflow" is occasionally used to describe array index errors in which the
				index is negative.</Alternate_Terms>
			<Observed_Examples>
				<Observed_Example>
					<Observed_Example_Reference>CVE-2004-0816</Observed_Example_Reference>
					<Observed_Example_Description>Integer underflow in firewall via malformed packet.</Observed_Example_Description>
				</Observed_Example>
				<Observed_Example>
					<Observed_Example_Reference>CVE-2004-1002</Observed_Example_Reference>
					<Observed_Example_Description>Integer underflow by packet with invalid length.</Observed_Example_Description>
				</Observed_Example>
				<Observed_Example>
					<Observed_Example_Reference>CVE-2005-0199</Observed_Example_Reference>
					<Observed_Example_Description>Long input causes incorrect length calculation.</Observed_Example_Description>
				</Observed_Example>
				<Observed_Example>
					<Observed_Example_Reference>CVE-2005-1891</Observed_Example_Reference>
					<Observed_Example_Description>Malformed icon causes integer underflow in loop counter variable.</Observed_Example_Description>
				</Observed_Example>
			</Observed_Examples>
			<Research_Gaps>Under-studied.</Research_Gaps>
				<Relationships>
				<Relationship>
					<Relationship_Views>
						<Relationship_View_ID Ordinal="Primary">1000</Relationship_View_ID>
					</Relationship_Views>
					<Relationship_Type>Weakness</Relationship_Type>
					<Relationship_Nature>ChildOf</Relationship_Nature>
					<Relationship_Target_ID>682</Relationship_Target_ID>
				</Relationship>
				<Relationship>
						<Relationship_Views>
							<Relationship_View_ID>1000</Relationship_View_ID>
						</Relationship_Views>
						<Relationship_Type>Category</Relationship_Type>
					<Relationship_Nature>ChildOf</Relationship_Nature>
					<Relationship_Target_ID>189</Relationship_Target_ID>
				</Relationship>
				</Relationships>
			<Source_Taxonomy Source_Taxonomy_Name="PLOVER">
				<Original_Node_Name>Integer underflow (wrap or wraparound)</Original_Node_Name>
			</Source_Taxonomy>
			<Applicable_Platforms>
				<Platform>C</Platform>
				<Platform>C++</Platform>
				<Platform>Java</Platform>
				<Platform>.NET</Platform>
			</Applicable_Platforms>
			<Time_of_Introduction>Implementation</Time_of_Introduction>
		</Common_Attributes>
	</Weakness>
                    <Weakness Weakness_ID="194" Weakness_Name="Incorrect Sign Extension" Weakness_Abstraction="Base" Weakness_Status="Incomplete">
		<Common_Attributes>
			<Description>
				<Description_Summary>If one extends a signed number incorrectly, if negative numbers are used, an incorrect
				extension may result.</Description_Summary>
			</Description>
			<Likelihood_of_Exploit>High</Likelihood_of_Exploit>
			<Common_Consequences>
				<Common_Consequence>Integrity: If one attempts to sign extend a negative variable with an unsigned
					extension algorithm, it will produce an incorrect result.</Common_Consequence>
				<Common_Consequence>Authorization: Sign extension errors -- if they are used to collect
					information from smaller signed sources -- can often create buffer overflows and other memory
					based problems.</Common_Consequence>
			</Common_Consequences>
			<Potential_Mitigations>
				<Mitigation>Implementation: Use a sign extension library or standard function to extend signed
					numbers.</Mitigation>
				<Mitigation>Implementation: When extending signed numbers fill in the new bits with 0 if the sign
					bit is 0 or fill the new bits with 1 if the sign bit is 1.</Mitigation>
			</Potential_Mitigations>
			<Demonstrative_Example>
				<Example_Code>
					<Example_Block>
						<Example_Code_Block>
							<Code_Example_Language>C</Code_Example_Language>
							<Code_Block><![CDATA[struct fakei]]><![CDATA[nt { short f0; short zeros; }; 
]]><![CDATA[					struct fakeint strange; 
		]]><![CDATA[			struct fakeint strange2; 
			]]><![CDATA[		strange.f0=-240; 
					strange]]><![CDATA[2.f0=240; 
					strange2.zeros=0]]><![CDATA[;
					strange.zeros=0; 
					pr]]><![CDATA[intf("%d %d\n",strange.f0,strang]]><![CDATA[e);
					printf("%d %d\n",strang]]><![CDATA[e2.f0,strange2);]]></Code_Block>
						</Example_Code_Block>
					</Example_Block>
				</Example_Code>
			</Demonstrative_Example>
			<Context_Notes>Sign extension errors -- if they are used to collect information from smaller signed
				sources -- can often create buffer overflows and other memory based problems.</Context_Notes>
				<Relationships>
				<Relationship>
					<Relationship_Views>
						<Relationship_View_ID Ordinal="Primary">1000</Relationship_View_ID>
					</Relationship_Views>
					<Relationship_Type>Weakness</Relationship_Type>
					<Relationship_Nature>ChildOf</Relationship_Nature>
					<Relationship_Target_ID>682</Relationship_Target_ID>
				</Relationship>
				<Relationship>
						<Relationship_Views>
							<Relationship_View_ID>1000</Relationship_View_ID>
						</Relationship_Views>
						<Relationship_Type>Category</Relationship_Type>
					<Relationship_Nature>ChildOf</Relationship_Nature>
					<Relationship_Target_ID>189</Relationship_Target_ID>
				</Relationship>
				</Relationships>
			<Source_Taxonomy Source_Taxonomy_Name="CLASP">
				<Original_Node_Name>Sign extension error</Original_Node_Name>
			</Source_Taxonomy>
			<Applicable_Platforms>
				<Platform>C</Platform>
				<Platform>C++</Platform>
				<Platform>Java</Platform>
				<Platform>.NET</Platform>
			</Applicable_Platforms>
			<Time_of_Introduction>Implementation</Time_of_Introduction>
		</Common_Attributes>
	</Weakness>
                    <Weakness Weakness_ID="195" Weakness_Name="Signed to Unsigned Conversion Error" Weakness_Abstraction="Variant" Weakness_Status="Draft">
		<Common_Attributes>
			<Description>
				<Description_Summary>A signed-to-unsigned conversion error takes place when a signed primitive is used as an
				unsigned value, usually as a size variable.</Description_Summary>
			</Description>
			<Common_Consequences>
				<Common_Consequence>Conversion between signed and unsigned values can lead to a variety of errors,
					but from a security standpoint is most commonly associated with integer overflow and buffer
					overflow vulnerabilities. </Common_Consequence>
			</Common_Consequences>
			<Demonstrative_Example>
				<Example_Code>
					<PreText>In this example the variable amount can hold a negative value when it is returned.
						Because the function is declared to return an unsigned int, amount will be implicitly
						converted to unsigned. </PreText>
					<Example_Block>
						<Example_Code_Block>
							<Code_Block><![CDATA[unsigned int readda]]><![CDATA[ta () {
					  int amount = 0; 
]]><![CDATA[					  ...
					  if (result == ]]><![CDATA[ERROR)
					    amount = -1;
			]]><![CDATA[		  ... 
					  return amount;
	]]><![CDATA[				}]]></Code_Block>
						</Example_Code_Block>
					</Example_Block>
					<PostText>If the error condition in the code above is met, then the return value of readdata()
						will be 4,294,967,295 on a system uses 32-bit integers. </PostText>
				</Example_Code>
				<Example_Code>
					<PreText>In this example, depending on the return value of accecssmainframe(), the variable
						amount can hold a negative value when it is returned. Because the function is declared to
						return an unsigned value, amount will be implicitly cast to an unsigned number. </PreText>
					<Example_Block>
						<Example_Code_Block>
							<Code_Block><![CDATA[unsigne]]><![CDATA[d int readdata () {
					  int a]]><![CDATA[mount = 0; 
					  ...
					  am]]><![CDATA[ount = accessmainframe(); 
					]]><![CDATA[  ...
					  return amount;
				]]><![CDATA[	}]]></Code_Block>
						</Example_Code_Block>
					</Example_Block>
					<PostText>If the return value of accessmainframe() is -1, then the return value of readdata()
						will be 4,294,967,295 on a system that uses 32-bit integers. </PostText>
				</Example_Code>
			</Demonstrative_Example>
			<Observed_Examples>
				<Observed_Example>
					<Observed_Example_Reference>CVE-2007-4268</Observed_Example_Reference>
					<Observed_Example_Description>Chain: integer signedness passes signed comparison, leads to
						heap overflow</Observed_Example_Description>
				</Observed_Example>
			</Observed_Examples>
			<Context_Notes>It is dangerous to rely on implicit casts between signed and unsigned numbers because
				the result can take on an unexpected value and violate weak assumptions made elsewhere in the
				program. </Context_Notes>
				<Relationships>
				<Relationship>
					<Relationship_Views>
						<Relationship_View_ID Ordinal="Primary">1000</Relationship_View_ID>
					</Relationship_Views>
					<Relationship_Type>Weakness</Relationship_Type>
					<Relationship_Nature>ChildOf</Relationship_Nature>
					<Relationship_Target_ID>681</Relationship_Target_ID>
				</Relationship>
				<Relationship>
						<Relationship_Views>
							<Relationship_View_ID>1000</Relationship_View_ID>
						</Relationship_Views>
						<Relationship_Type>Category</Relationship_Type>
					<Relationship_Nature>ChildOf</Relationship_Nature>
					<Relationship_Target_ID>189</Relationship_Target_ID>
				</Relationship>
				<Relationship>
						<Relationship_Views>
							<Relationship_View_ID>1000</Relationship_View_ID>
						</Relationship_Views>
						<Relationship_Type>Weakness</Relationship_Type>
					<Relationship_Nature>CanPrecede</Relationship_Nature>
					<Relationship_Target_ID>122</Relationship_Target_ID>
				</Relationship>
				</Relationships>
			<Source_Taxonomy Source_Taxonomy_Name="CLASP">
				<Original_Node_Name>Signed to unsigned conversion error</Original_Node_Name>
			</Source_Taxonomy>
			<Applicable_Platforms>
				<Platform>C</Platform>
				<Platform>C++</Platform>
			</Applicable_Platforms>
			<Time_of_Introduction>Implementation</Time_of_Introduction>
		</Common_Attributes>
	</Weakness>
                    <Weakness Weakness_ID="196" Weakness_Name="Unsigned to Signed Conversion Error" Weakness_Abstraction="Variant" Weakness_Status="Draft">
		<Common_Attributes>
			<Description>
				<Description_Summary>An unsigned-to-signed conversion error takes place when a large unsigned primitive is
				used as a signed value.</Description_Summary>
			</Description>
			<Likelihood_of_Exploit>Medium</Likelihood_of_Exploit>
			<Common_Consequences>
				<Common_Consequence>Availability: Incorrect sign conversions generally lead to undefined behavior,
					and therefore crashes.</Common_Consequence>
				<Common_Consequence>Integrity: If a poor cast lead to a buffer overflow or similar condition, data
					integrity may be affected.</Common_Consequence>
				<Common_Consequence>Access control (instruction processing): Improper signed-to-unsigned
					conversions without proper checking can sometimes trigger buffer overflows which can be used
					to execute arbitrary code. This is usually outside the scope of a program's implicit security
					policy.</Common_Consequence>
			</Common_Consequences>
			<Potential_Mitigations>
				<Mitigation>Requirements specification: Choose a language which is not subject to these casting
					flaws.</Mitigation>
				<Mitigation>Design: Design object accessor functions to implicitly check values for valid sizes.
					Ensure that all functions which will be used as a size are checked previous to use as a size.
					If the language permits, throw exceptions rather than using in-band errors.</Mitigation>
				<Mitigation>Implementation: Error check the return values of all functions. Be aware of implicit
					casts made, and use unsigned variables for sizes if at all possible.</Mitigation>
			</Potential_Mitigations>
			<Demonstrative_Example>
				<Example_Code>
					<PreText>In the following example, it is possible to request that memcpy move a much larger
						segment of memory than assumed:</PreText>
					<Example_Block>
						<Example_Code_Block>
							<Code_Block><![CDATA[int returnChunkSize(void *) ]]><![CDATA[{ 
					  /* if chunk info is va]]><![CDATA[lid, return the size of usable m]]><![CDATA[emory, 
					  * else, return -1]]><![CDATA[ to indicate an error
					  */ ]]><![CDATA[
					  ...
					}
					int main]]><![CDATA[() {
					  ... 
					  memcpy(d]]><![CDATA[estBuf, srcBuf, (returnChunkSize]]><![CDATA[(destBuf)-1)); 
					  ... 
				]]><![CDATA[	}]]></Code_Block>
						</Example_Code_Block>
					</Example_Block>
					<PostText> If returnChunkSize() happens to encounter an error, and returns -1, memcpy will
						assume that the value is unsigned and therefore interpret it as MAXINT-1, therefore
						copying far more memory than is likely available in the destination buffer. </PostText>
				</Example_Code>
			</Demonstrative_Example>
			<Context_Notes>Often, functions will return negative values to indicate a failure state. In the case
				of functions which return values which are meant to be used as sizes, negative return values can
				have unexpected results. If these values are passed to the standard memory copy or allocation
				functions, they will implicitly cast the negative error-indicating value to a large unsigned
				value. In the case of allocation, this may not be an issue; however, in the case of memory and
				string copy functions, this can lead to a buffer overflow condition which may be exploitable.
				Also, if the variables in question are used as indexes into a buffer, it may result in a buffer
				underflow condition. </Context_Notes>
			<Context_Notes>Although less frequent an issue than signed-to-unsigned casting, unsigned-to-signed
				casting can be the perfect precursor to dangerous buffer underwrite conditions that allow
				attackers to move down the stack where they otherwise might not have access in a normal buffer
				overflow condition. Buffer underwrites occur frequently when large unsigned values are cast to
				signed values, and then used as indexes into a buffer or for pointer arithmetic.</Context_Notes>
			<Relationships>
				<Relationship>
					<Relationship_Views>
						<Relationship_View_ID Ordinal="Primary">1000</Relationship_View_ID>
					</Relationship_Views>
					<Relationship_Type>Weakness</Relationship_Type>
					<Relationship_Nature>ChildOf</Relationship_Nature>
					<Relationship_Target_ID>681</Relationship_Target_ID>
				</Relationship>
				<Relationship>
						<Relationship_Views>
							<Relationship_View_ID>1000</Relationship_View_ID>
						</Relationship_Views>
						<Relationship_Type>Category</Relationship_Type>
					<Relationship_Nature>ChildOf</Relationship_Nature>
					<Relationship_Target_ID>189</Relationship_Target_ID>
				</Relationship>
				<Relationship>
						<Relationship_Views>
							<Relationship_View_ID>1000</Relationship_View_ID>
						</Relationship_Views>
						<Relationship_Type>Weakness</Relationship_Type>
					<Relationship_Nature>CanAlsoBe</Relationship_Nature>
					<Relationship_Target_ID>124</Relationship_Target_ID>
				</Relationship>
				<Relationship>
						<Relationship_Views>
							<Relationship_View_ID>1000</Relationship_View_ID>
						</Relationship_Views>
						<Relationship_Type>Compound_Element</Relationship_Type>
					<Relationship_Nature>CanAlsoBe</Relationship_Nature>
					<Relationship_Target_ID>120</Relationship_Target_ID>
				</Relationship>
				</Relationships>
			<Source_Taxonomy Source_Taxonomy_Name="CLASP">
				<Original_Node_Name>Unsigned to signed conversion error</Original_Node_Name>
			</Source_Taxonomy>
			<Applicable_Platforms>
				<Platform>C</Platform>
				<Platform>C++</Platform>
			</Applicable_Platforms>
			<Time_of_Introduction>Implementation</Time_of_Introduction>
			<Related_Attack_Patterns>
				<Related_Attack_Pattern>
					<CAPEC_ID>92<!--Forced Integer Overflow--></CAPEC_ID>
				</Related_Attack_Pattern>
			</Related_Attack_Patterns>
		</Common_Attributes>
	</Weakness>
                    <Weakness Weakness_ID="197" Weakness_Name="Numeric Truncation Error" Weakness_Abstraction="Base" Weakness_Status="Incomplete">
		<Common_Attributes>
			<Description>
				<Description_Summary>Truncation errors occur when a primitive is cast to a primitive of a smaller size and
				data is lost in the conversion.</Description_Summary>
			</Description>
			<Likelihood_of_Exploit>Low</Likelihood_of_Exploit>
			<Common_Consequences>
				<Common_Consequence>Integrity: The true value of the data is lost and corrupted data is
				used.</Common_Consequence>
			</Common_Consequences>
			<Potential_Mitigations>
				<Mitigation>Implementation: Ensure that no casts, implicit or explicit, take place that move from
					a larger size primitive or a smaller size primitive.</Mitigation>
			</Potential_Mitigations>
			<Demonstrative_Example>
				<Example_Code>
					<PreText>This example, while not exploitable, shows the possible mangling of values associated
						with truncation errors:</PreText>
					<Example_Block>
						<Example_Code_Block>
							<Code_Block><![CDATA[#inclu]]><![CDATA[de <stdio.h>
					int main() {
	]]><![CDATA[				  int intPrimitive;
					  s]]><![CDATA[hort shortPrimitive;
					  intP]]><![CDATA[rimitive = (int)(~((int)0) ^ (1 ]]><![CDATA[<< (sizeof(int)*8-1)));
					  s]]><![CDATA[hortPrimitive = intPrimitive;
		]]><![CDATA[			  printf("Int MAXINT: %d\nSho]]><![CDATA[rt MAXINT: %d\n",
					  intPrim]]><![CDATA[itive, shortPrimitive);
					  r]]><![CDATA[eturn (0);
					}]]></Code_Block>
						</Example_Code_Block>
					</Example_Block>
					<PostText>The above code, when compiled and run, returns the following output: Int MAXINT:
						2147483647 Short MAXINT: -1 A frequent paradigm for such a problem being exploitable is
						when the truncated value is used as an array index, which can happen implicitly when
						64-bit values are used as indexes, as they are truncated to 32 bits. </PostText>
				</Example_Code>
			</Demonstrative_Example>
			<Context_Notes>When a primitive is cast to a smaller primitive, the high order bits of the large value
				are lost in the conversion, potentially resulting in an unexpected value that is not equal to the
				original value. This value may be required as an index into a buffer, a loop iterator, or simply
				necessary state data. In any case, the value cannot be trusted and the system will be in an
				undefined state. While this method may be employed viably to isolate the low bits of a value, this
				usage is rare, and truncation usually implies that an implementation error has occurred.</Context_Notes>
			<Research_Gaps>Under-studied and under-reported.</Research_Gaps>
				<Relationships>
				<Relationship>
					<Relationship_Views>
						<Relationship_View_ID Ordinal="Primary">1000</Relationship_View_ID>
					</Relationship_Views>
					<Relationship_Type>Weakness</Relationship_Type>
					<Relationship_Nature>ChildOf</Relationship_Nature>
					<Relationship_Target_ID>681</Relationship_Target_ID>
				</Relationship>
				<Relationship>
						<Relationship_Views>
							<Relationship_View_ID>1000</Relationship_View_ID>
						</Relationship_Views>
						<Relationship_Type>Category</Relationship_Type>
					<Relationship_Nature>ChildOf</Relationship_Nature>
					<Relationship_Target_ID>189</Relationship_Target_ID>
				</Relationship>
				<Relationship>
						<Relationship_Views>
							<Relationship_View_ID>1000</Relationship_View_ID>
						</Relationship_Views>
						<Relationship_Type>Weakness</Relationship_Type>
					<Relationship_Nature>CanAlsoBe</Relationship_Nature>
					<Relationship_Target_ID>195</Relationship_Target_ID>
				</Relationship>
				<Relationship>
						<Relationship_Views>
							<Relationship_View_ID>1000</Relationship_View_ID>
						</Relationship_Views>
						<Relationship_Type>Weakness</Relationship_Type>
					<Relationship_Nature>CanAlsoBe</Relationship_Nature>
					<Relationship_Target_ID>196</Relationship_Target_ID>
				</Relationship>
				<Relationship>
						<Relationship_Views>
							<Relationship_View_ID>1000</Relationship_View_ID>
						</Relationship_Views>
						<Relationship_Type>Category</Relationship_Type>
					<Relationship_Nature>CanAlsoBe</Relationship_Nature>
					<Relationship_Target_ID>192</Relationship_Target_ID>
				</Relationship>
				<Relationship>
						<Relationship_Views>
							<Relationship_View_ID>1000</Relationship_View_ID>
						</Relationship_Views>
						<Relationship_Type>Weakness</Relationship_Type>
					<Relationship_Nature>CanAlsoBe</Relationship_Nature>
					<Relationship_Target_ID>194</Relationship_Target_ID>
				</Relationship>
				</Relationships>
			<Source_Taxonomy Source_Taxonomy_Name="PLOVER">
				<Original_Node_Name>Numeric truncation error</Original_Node_Name>
			</Source_Taxonomy>
			<Source_Taxonomy Source_Taxonomy_Name="CLASP">
				<Original_Node_Name>Truncation error</Original_Node_Name>
			</Source_Taxonomy>
			<Applicable_Platforms>
				<Platform>C</Platform>
				<Platform>C++</Platform>
				<Platform>Java</Platform>
				<Platform>.NET</Platform>
			</Applicable_Platforms>
			<Time_of_Introduction>Implementation</Time_of_Introduction>
		</Common_Attributes>
	</Weakness>
                    <Weakness Weakness_ID="242" Weakness_Name="Use of Inherently Dangerous Function" Weakness_Abstraction="Class" Weakness_Status="Draft">
		<Common_Attributes>
			<Description>
				<Description_Summary>The program calls a function that
			can never be guaranteed to work safely.</Description_Summary>
			</Description>
			<Likelihood_of_Exploit>High</Likelihood_of_Exploit>
			<Weakness_Ordinality>Primary (Weakness exists independent of other weaknesses)</Weakness_Ordinality>
			<Causal_Nature>Explicit (This is an explicit weakness resulting from behavior of the developer)</Causal_Nature>
			<Context_Notes>Certain functions behave in dangerous ways regardless of how they are used. Functions
				in this category were often implemented without taking security concerns into account. The gets()
				function is unsafe because it does not perform bounds checking on the size of its input. An
				attacker can easily send arbitrarily-sized input to gets() and overflow the destination buffer.
				The &gt; operator is unsafe to use when reading into a character buffer because it does not
				perform bounds checking on the size of its input. An attacker can easily send arbitrarily-sized
				input to the &gt; operator and overflow the destination buffer. </Context_Notes>
				<Relationships>
				<Relationship>
						<Relationship_Views>
							<Relationship_View_ID Ordinal="Primary">1000</Relationship_View_ID>
						</Relationship_Views>
						<Relationship_Type>Category</Relationship_Type>
					<Relationship_Nature>ChildOf</Relationship_Nature>
					<Relationship_Target_ID>18</Relationship_Target_ID>
				</Relationship>
				</Relationships>
			<Source_Taxonomy Source_Taxonomy_Name="7 Pernicious Kingdoms">
				<Original_Node_Name>Dangerous Functions</Original_Node_Name>
			</Source_Taxonomy>
			<Applicable_Platforms>
				<Platform>C</Platform>
				<Platform>C++</Platform>
			</Applicable_Platforms>
			<Time_of_Introduction>Implementation</Time_of_Introduction>
		</Common_Attributes>
	</Weakness>
                    <Weakness Weakness_ID="243" Weakness_Name="Failure to Change Working Directory in chroot Jail" Weakness_Abstraction="Variant" Weakness_Status="Draft">
		<Common_Attributes>
			<Description>
				<Description_Summary>When a product uses the chroot() system call to
				create a jail, but does not change the working
				directory afterward,
				this might allow attackers to access files outside of the
				jail.</Description_Summary>
			</Description>
			<Likelihood_of_Exploit>High</Likelihood_of_Exploit>
			<Weakness_Ordinality>Resultant (Weakness is typically related to the presence of some other weaknesses)</Weakness_Ordinality>
			<Causal_Nature>Explicit (This is an explicit weakness resulting from behavior of the developer)</Causal_Nature>
			<Affected_Resource>File/Directory</Affected_Resource>
			<Demonstrative_Example>
				<Example_Code>
					<PreText>Example: Consider the following source code from a (hypothetical) FTP server: </PreText>
					<Example_Block>
						<Example_Code_Block>
							<Code_Block><![CDATA[chroot("/va]]><![CDATA[r/ftproot");
					...
					fgets]]><![CDATA[(filename, sizeof(filename), net]]><![CDATA[work);
					localfile = fopen(fi]]><![CDATA[lename, "r");
					while ((len =]]><![CDATA[ fread(buf, 1, sizeof(buf), loca]]><![CDATA[lfile)) != EOF) { 
					  fwrite]]><![CDATA[(buf, 1, sizeof(buf), network); ]]><![CDATA[
					}
					fclose(localfile);]]></Code_Block>
						</Example_Code_Block>
					</Example_Block>
					<PostText> This code is responsible for reading a filename from the network, opening the
						corresponding file on the local machine, and sending the contents over the network. This
						code could be used to implement the FTP GET command. The FTP server calls chroot() in its
						initialization routines in an attempt to prevent access to files outside of /var/ftproot.
						But because the server fails to change the current working directory by calling
						chdir("/"), an attacker could request the file "../../../../../etc/passwd" and obtain a
						copy of the system password file. </PostText>
				</Example_Code>
			</Demonstrative_Example>
			<Context_Notes>The chroot() system call allows a process to change its perception of the root
				directory of the file system. After properly invoking chroot(), a process cannot access any files
				outside the directory tree defined by the new root directory. Such an environment is called a
				chroot jail and is commonly used to prevent the possibility that a processes could be subverted
				and used to access unauthorized files. For instance, many FTP servers run in chroot jails to
				prevent an attacker who discovers a new vulnerability in the server from being able to download
				the password file or other sensitive files on the system. Improper use of chroot() may allow
				attackers to escape from the chroot jail. The chroot() function call does not change the process's
				current working directory, so relative paths may still refer to file system resources outside of
				the chroot jail after chroot() has been called. </Context_Notes>
				<Relationships>
				<Relationship>
						<Relationship_Views>
							<Relationship_View_ID>1000</Relationship_View_ID>
						</Relationship_Views>
						<Relationship_Type>Weakness</Relationship_Type>
					<Relationship_Nature>ChildOf</Relationship_Nature>
					<Relationship_Target_ID>573</Relationship_Target_ID>
				</Relationship>
				<Relationship>
						<Relationship_Views>
							<Relationship_View_ID Ordinal="Primary">1000</Relationship_View_ID>
						</Relationship_Views>
						<Relationship_Type>Weakness</Relationship_Type>
					<Relationship_Nature>ChildOf</Relationship_Nature>
					<Relationship_Target_ID>669</Relationship_Target_ID>
				</Relationship>
				<Relationship>
						<Relationship_Views>
							<Relationship_View_ID Ordinal="Primary">631</Relationship_View_ID>
						</Relationship_Views>
						<Relationship_Type>Category</Relationship_Type>
					<Relationship_Nature>ChildOf</Relationship_Nature>
					<Relationship_Target_ID>632</Relationship_Target_ID>
				</Relationship>
				</Relationships>
			<Source_Taxonomy Source_Taxonomy_Name="7 Pernicious Kingdoms">
				<Original_Node_Name>Directory Restriction</Original_Node_Name>
			</Source_Taxonomy>
			<Applicable_Platforms>
				<Platform>C</Platform>
				<Platform>C++</Platform>
			</Applicable_Platforms>
			<Time_of_Introduction>Implementation</Time_of_Introduction>
		</Common_Attributes>
	</Weakness>
                    <Weakness Weakness_ID="244" Weakness_Name="Failure to Clear Heap Memory Before Release" Weakness_Abstraction="Variant" Weakness_Status="Draft">
		<Common_Attributes>
			<Description>
				<Description_Summary>Using realloc() to resize buffers that store sensitive information can leave the
				sensitive information exposed to attack, because it is not removed from memory.</Description_Summary>
			</Description>
			<Affected_Resource>Memory</Affected_Resource>
			<Demonstrative_Example>
				<Example_Code>
					<PreText> The following code calls realloc() on a buffer containing sensitive data: </PreText>
					<Example_Block>
						<Example_Code_Block>
							<Code_Block><![CDATA[cleartext_buffer = g]]><![CDATA[et_secret();
					... 
					clea]]><![CDATA[rtext_buffer = realloc(cleartext]]><![CDATA[_buffer, 1024);
					...
					sc]]><![CDATA[rub_memory(cleartext_buffer, 102]]><![CDATA[4); ]]></Code_Block>
						</Example_Code_Block>
					</Example_Block>
					<PostText> There is an attempt to scrub the sensitive data from memory, but realloc() is used,
						so a copy of the data can still be exposed in the memory originally allocated for
						cleartext_buffer. </PostText>
				</Example_Code>
			</Demonstrative_Example>
			<Context_Notes>Heap inspection vulnerabilities occur when sensitive data, such as a password or an
				encryption key, can be exposed to an attacker because they are not removed from memory. The
				realloc() function is commonly used to increase the size of a block of allocated memory. This
				operation often requires copying the contents of the old memory block into a new and larger block.
				This operation leaves the contents of the original block intact but inaccessible to the program,
				preventing the program from being able to scrub sensitive data from memory. If an attacker can
				later examine the contents of a memory dump, the sensitive data could be exposed. </Context_Notes>
			<Context_Notes>Be careful using {vfork, fork} in security sensitive code. The process state will not
				be cleaned up and will contain traces of data from past use.</Context_Notes>
				<Relationships>
				<Relationship>
					<Relationship_Views>
						<Relationship_View_ID Ordinal="Primary">1000</Relationship_View_ID>
					</Relationship_Views>
					<Relationship_Type>Weakness</Relationship_Type>
					<Relationship_Nature>ChildOf</Relationship_Nature>
					<Relationship_Target_ID>404</Relationship_Target_ID>
				</Relationship>
				<Relationship>
						<Relationship_Views>
							<Relationship_View_ID>1000</Relationship_View_ID>
						</Relationship_Views>
						<Relationship_Type>Weakness</Relationship_Type>
					<Relationship_Nature>ChildOf</Relationship_Nature>
					<Relationship_Target_ID>669</Relationship_Target_ID>
				</Relationship>
				<Relationship>
						<Relationship_Views>
							<Relationship_View_ID Ordinal="Primary">630</Relationship_View_ID>
						</Relationship_Views>
						<Relationship_Type>View</Relationship_Type>
					<Relationship_Nature>ChildOf</Relationship_Nature>
					<Relationship_Target_ID>630</Relationship_Target_ID>
				</Relationship>
				<Relationship>
						<Relationship_Views>
							<Relationship_View_ID Ordinal="Primary">631</Relationship_View_ID>
						</Relationship_Views>
						<Relationship_Type>Category</Relationship_Type>
					<Relationship_Nature>ChildOf</Relationship_Nature>
					<Relationship_Target_ID>633</Relationship_Target_ID>
				</Relationship>
				</Relationships>
			<Source_Taxonomy Source_Taxonomy_Name="7 Pernicious Kingdoms">
				<Original_Node_Name>Heap Inspection</Original_Node_Name>
			</Source_Taxonomy>
			<Applicable_Platforms>
				<Platform>C</Platform>
				<Platform>C++</Platform>
			</Applicable_Platforms>
			<Time_of_Introduction>Implementation</Time_of_Introduction>
		</Common_Attributes>
	</Weakness>
                    <Weakness Weakness_ID="248" Weakness_Name="Uncaught Exception" Weakness_Abstraction="Base" Weakness_Status="Draft">
		<Common_Attributes>
			<Description>
				<Description_Summary>Failing to catch an exception thrown from a dangerous function can potentially cause the
				program to crash.</Description_Summary>
			</Description>
			<Demonstrative_Example>
				<Example_Code>
					<PreText>The _alloca() function allocates memory on the stack. If an allocation request is too
						large for the available stack space, _alloca() throws an exception. If the exception is
						not caught, the program will crash, potentially enabling a denial of service attack.
						_alloca() has been deprecated as of Microsoft Visual Studio 2005®. It has been replaced
						with the more secure _alloca_s().</PreText>
				</Example_Code>
				<Example_Code>
					<PreText>EnterCriticalSection() can raise an exception, potentially causing the program to
						crash. Under operating systems prior to Windows 2000, the EnterCriticalSection() function
						can raise an exception in low memory situations. If the exception is not caught, the
						program will crash, potentially enabling a denial of service attack. </PreText>
				</Example_Code>
			</Demonstrative_Example>
				<Relationships>
				<Relationship>
						<Relationship_Views>
							<Relationship_View_ID>1000</Relationship_View_ID>
						</Relationship_Views>
						<Relationship_Type>Category</Relationship_Type>
					<Relationship_Nature>ChildOf</Relationship_Nature>
					<Relationship_Target_ID>389</Relationship_Target_ID>
				</Relationship>
				<Relationship>
					<Relationship_Views>
						<Relationship_View_ID Ordinal="Primary">1000</Relationship_View_ID>
					</Relationship_Views>
					<Relationship_Type>Weakness</Relationship_Type>
					<Relationship_Nature>ChildOf</Relationship_Nature>
					<Relationship_Target_ID>691</Relationship_Target_ID>
				</Relationship>
				</Relationships>
			<Source_Taxonomy Source_Taxonomy_Name="7 Pernicious Kingdoms">
				<Original_Node_Name>Often Misused: Exception Handling</Original_Node_Name>
			</Source_Taxonomy>
			<Applicable_Platforms>
				<Platform>C</Platform>
				<Platform>C++</Platform>
				<Platform>Java</Platform>
				<Platform>.NET</Platform>
			</Applicable_Platforms>
			<Related_Attack_Patterns>
				<Related_Attack_Pattern>
					<CAPEC_ID>54<!--Probing an Application Through Targeting its Error Reporting--></CAPEC_ID>
				</Related_Attack_Pattern>
			</Related_Attack_Patterns>
		</Common_Attributes>
	</Weakness>
                    <Weakness Weakness_ID="249" Weakness_Name="Often Misused: Path Manipulation" Weakness_Abstraction="Variant" Weakness_Status="Incomplete">
		<Common_Attributes>
			<Description>
				<Description_Summary>Passing an inadequately-sized output buffer to a path manipulation function can result in
			a buffer overflow.</Description_Summary>
			</Description>
			<Affected_Resource>Memory</Affected_Resource>
			<Affected_Resource>File/Directory</Affected_Resource>
			<Potential_Mitigations>
				<Mitigation>Always specify output buffers large enough to handle the maximum-size possible result from path manipulation functions.</Mitigation>
			</Potential_Mitigations>
			<Demonstrative_Example>
				<Example_Code>
					<PreText>The C standard library function realpath() takes two arguments. The first argument
						specifies a filename to be converted to canonical form. The second argument specifies an
						output buffer. Regardless of the length of the canonicalized file name, realpath() will
						not write more than PATH_MAX bytes to the output buffer. Some programmers incorrectly
						assume that, by allocating a buffer of size PATH_MAX, there will always be enough room in
						the buffer to hold any file name that might be found on the system. However, PATH_MAX only
						bounds the longest possible relative path that can be passed to the kernel in a single
						call. On most Unix and Linux systems, there is no easily-determined maximum length for a
						path.</PreText>
				</Example_Code>
				<Example_Code>
					<Example_Block>
						<Example_Code_Block>
							<Code_Block><![CDATA[char *createOutput]]><![CDATA[Directory(char *name) { 
					  ]]><![CDATA[char outputDirectoryName[128]; 
]]><![CDATA[					  if (getCurrentDirectory(1]]><![CDATA[28, outputDirectoryName) == 0) {]]><![CDATA[
					    return null; 
					  }]]><![CDATA[ 
					  if (!PathAppend(outputD]]><![CDATA[irectoryName, "output")) {
					]]><![CDATA[    return null; 
					  }
					]]><![CDATA[  if (!PathAppend(outputDirector]]><![CDATA[yName, name)) { 
					    return]]><![CDATA[ null; 
					  }
					  if (SHCr]]><![CDATA[eateDirectoryEx(NULL, outputDire]]><![CDATA[ctoryName, NULL) != ERROR_SUCCES]]><![CDATA[S) { 
					    return null; 
			]]><![CDATA[		  }
					    return StrDup(out]]><![CDATA[putDirectoryName); 
					}]]></Code_Block>
						</Example_Code_Block>
					</Example_Block>
					<PostText>In this example the function creates a directory named "output\&lt;name&gt;"
						in the current directory and returns a heap-allocated copy of its name. For most values of
						the current directory and the name parameter, this function will work properly. However,
						if the name parameter is particularly long, then the second call to PathAppend() could
						overflow the outputDirectoryName buffer, which is smaller than MAX_PATH bytes. </PostText>
				</Example_Code>
			</Demonstrative_Example>
			<Context_Notes>Windows provides a large number of utility functions that manipulate buffers containing
				filenames. In most cases, the result is returned in a buffer that is passed in as input. (Usually
				the filename is modified in place.) Most functions require the buffer to be at least MAX_PATH
				bytes in length, but you should check the documentation for each function individually. If the
				buffer is not large enough to store the result of the manipulation, a buffer overflow can occur.</Context_Notes>
				<Relationships>
				<Relationship>
						<Relationship_Views>
							<Relationship_View_ID Ordinal="Primary">1000</Relationship_View_ID>
						</Relationship_Views>
						<Relationship_Type>Compound_Element</Relationship_Type>
					<Relationship_Nature>ChildOf</Relationship_Nature>
					<Relationship_Target_ID>120</Relationship_Target_ID>
				</Relationship>
				<Relationship>
						<Relationship_Views>
							<Relationship_View_ID Ordinal="Primary">631</Relationship_View_ID>
						</Relationship_Views>
						<Relationship_Type>Category</Relationship_Type>
					<Relationship_Nature>ChildOf</Relationship_Nature>
					<Relationship_Target_ID>632</Relationship_Target_ID>
				</Relationship>
				<Relationship>
						<Relationship_Views>
							<Relationship_View_ID>631</Relationship_View_ID>
						</Relationship_Views>
						<Relationship_Type>Category</Relationship_Type>
					<Relationship_Nature>ChildOf</Relationship_Nature>
					<Relationship_Target_ID>633</Relationship_Target_ID>
				</Relationship>
				</Relationships>
			<Source_Taxonomy Source_Taxonomy_Name="7 Pernicious Kingdoms">
				<Original_Node_Name>Often Misused: File System</Original_Node_Name>
			</Source_Taxonomy>
			<Applicable_Platforms>
				<Platform>C</Platform>
				<Platform>C++</Platform>
			</Applicable_Platforms>
		</Common_Attributes>
	</Weakness>
                    <Weakness Weakness_ID="364" Weakness_Name="Signal Handler Race Condition" Weakness_Abstraction="Base" Weakness_Status="Incomplete">
		<Common_Attributes>
			<Description>
				<Description_Summary>Race conditions occur frequently in signal handlers, since they are asynchronous actions.
			These race conditions may have any number of root-causes and symptoms.</Description_Summary>
			</Description>
			<Functional_Area>Signals, interprocess communication</Functional_Area>
			<Likelihood_of_Exploit>Medium</Likelihood_of_Exploit>
			<Affected_Resource>System Process</Affected_Resource>
			<Common_Consequences>
				<Common_Consequence>Authorization: It may be possible to execute arbitrary code through the use of
					a write-what-where condition.</Common_Consequence>
				<Common_Consequence>Integrity: Signal race conditions often result in data
				corruption.</Common_Consequence>
			</Common_Consequences>
			<Potential_Mitigations>
				<Mitigation>Requirements specification: A language might be chosen, which is not subject to this
					flaw, through a guarantee of reentrant code.</Mitigation>
				<Mitigation>Design: Design signal handlers to only set flags rather than perform complex
					functionality.</Mitigation>
				<Mitigation>Implementation: Ensure that non-reentrant functions are not found in signal handlers.
					Also, use sanity checks to ensure that state is consistent be performing asynchronous actions
					which effect the state of execution.</Mitigation>
			</Potential_Mitigations>
			<Demonstrative_Example>
				<Example_Code>
					<Example_Block>
						<Example_Code_Block>
							<Code_Example_Language>C</Code_Example_Language>
							<Code_Block><![CDATA[#includ]]><![CDATA[e <signal.h>
					#include <sysl]]><![CDATA[og.h>
					#include <string.h>
	]]><![CDATA[				#include <stdlib.h>
					
		]]><![CDATA[			void *global1, *global2;
				]]><![CDATA[	char *what;
					void sh(int du]]><![CDATA[mmy) {
					  syslog(LOG_NOTICE,]]><![CDATA["%s\n",what);
					  free(global]]><![CDATA[2);
					  free(global1);
					 ]]><![CDATA[ sleep(10);
					  exit(0);
				]]><![CDATA[	}
						
					int main(int argc]]><![CDATA[,char* argv[]) {
					  what=arg]]><![CDATA[v[1];
					  global1=strdup(argv]]><![CDATA[[2]);
					  global2=malloc(340)]]><![CDATA[;
					  signal(SIGHUP,sh);
				]]><![CDATA[	  signal(SIGTERM,sh);
					  sl]]><![CDATA[eep(10);
					  exit(0);
					}]]></Code_Block>
						</Example_Code_Block>
					</Example_Block>
				</Example_Code>
			</Demonstrative_Example>
			<Observed_Examples>
				<Observed_Example>
					<Observed_Example_Reference>CVE-2001-1349</Observed_Example_Reference>
					<Observed_Example_Description/>
				</Observed_Example>
				<Observed_Example>
					<Observed_Example_Reference>CVE-2004-0794</Observed_Example_Reference>
					<Observed_Example_Description/>
				</Observed_Example>
				<Observed_Example>
					<Observed_Example_Reference>CVE-2004-2259</Observed_Example_Reference>
					<Observed_Example_Description/>
				</Observed_Example>
			</Observed_Examples>
			<Context_Notes>Signal race conditions are a common issue that have only recently been seen as
				exploitable. These issues occur when non-reentrant functions, or state-sensitive actions occur in
				the signal handler, where they may be called at any time. If these functions are called at an
				inopportune moment -- such as while a non-reentrant function is already running --, memory
				corruption occurs that may be exploitable. Another signal race condition commonly found occurs
				when free is called within a signal handler, resulting in a double free and therefore a
				write-what-where condition. This is a perfect example of a signal handler taking actions which
				cannot be accounted for in state. Even if a given pointer is set to NULL after it has been freed,
				a race condition still exists between the time the memory was freed and the pointer was set to
				NULL. This is especially prudent if the same signal handler has been set for more than one signal
				-- since it means that the signal handler itself may be reentered. </Context_Notes>
			<Research_Gaps>Probably under-studied.</Research_Gaps>
				<Relationships>
				<Relationship>
						<Relationship_Views>
							<Relationship_View_ID Ordinal="Primary">1000</Relationship_View_ID>
						</Relationship_Views>
						<Relationship_Type>Weakness</Relationship_Type>
					<Relationship_Nature>ChildOf</Relationship_Nature>
					<Relationship_Target_ID>362</Relationship_Target_ID>
				</Relationship>
				<Relationship>
						<Relationship_Views>
							<Relationship_View_ID>1000</Relationship_View_ID>
						</Relationship_Views>
						<Relationship_Type>Weakness</Relationship_Type>
					<Relationship_Nature>PeerOf</Relationship_Nature>
					<Relationship_Target_ID>415</Relationship_Target_ID>
				</Relationship>
				<Relationship>
						<Relationship_Views>
							<Relationship_View_ID>1000</Relationship_View_ID>
						</Relationship_Views>
						<Relationship_Type>Weakness</Relationship_Type>
					<Relationship_Nature>PeerOf</Relationship_Nature>
					<Relationship_Target_ID>416</Relationship_Target_ID>
				</Relationship>
				<Relationship>
						<Relationship_Views>
							<Relationship_View_ID>1000</Relationship_View_ID>
						</Relationship_Views>
						<Relationship_Type>Weakness</Relationship_Type>
					<Relationship_Nature>PeerOf</Relationship_Nature>
					<Relationship_Target_ID>479</Relationship_Target_ID>
				</Relationship>
				<Relationship>
						<Relationship_Views>
							<Relationship_View_ID>1000</Relationship_View_ID>
						</Relationship_Views>
						<Relationship_Type>Weakness</Relationship_Type>
					<Relationship_Nature>PeerOf</Relationship_Nature>
					<Relationship_Target_ID>123</Relationship_Target_ID>
				</Relationship>
				<Relationship>
						<Relationship_Views>
							<Relationship_View_ID Ordinal="Primary">631</Relationship_View_ID>
						</Relationship_Views>
						<Relationship_Type>Category</Relationship_Type>
					<Relationship_Nature>ChildOf</Relationship_Nature>
					<Relationship_Target_ID>634</Relationship_Target_ID>
				</Relationship>
				</Relationships>
			<Source_Taxonomy Source_Taxonomy_Name="PLOVER">
				<Original_Node_Name>Signal handler race condition</Original_Node_Name>
			</Source_Taxonomy>
			<Source_Taxonomy Source_Taxonomy_Name="7 Pernicious Kingdoms">
				<Original_Node_Name>Signal Handling Race Conditions</Original_Node_Name>
			</Source_Taxonomy>
			<Source_Taxonomy Source_Taxonomy_Name="CLASP">
				<Original_Node_Name>Race condition in signal handler</Original_Node_Name>
			</Source_Taxonomy>
			<Applicable_Platforms>
				<Platform>C</Platform>
				<Platform>C++</Platform>
			</Applicable_Platforms>
		</Common_Attributes>
	</Weakness>
                    <Weakness Weakness_ID="365" Weakness_Name="Race Condition in Switch" Weakness_Abstraction="Base" Weakness_Status="Draft">
		<Common_Attributes>
			<Description>
				<Description_Summary>The code contains a switch
				statement in which the switched variable can be
				modified while the switch is still executing,
				resulting in unexpected behavior.</Description_Summary>
			</Description>
			<Likelihood_of_Exploit>Medium</Likelihood_of_Exploit>
			<Common_Consequences>
				<Common_Consequence>Undefined: This flaw will result in the system state going out of
				sync.</Common_Consequence>
			</Common_Consequences>
			<Potential_Mitigations>
				<Mitigation>Implementation: Variables that may be subject to race conditions should be locked for
					the duration of any switch statements.</Mitigation>
			</Potential_Mitigations>
			<Demonstrative_Example>
				<Example_Code>
					<Example_Block>
						<Example_Code_Block>
							<Code_Example_Language>C</Code_Example_Language>
							<Code_Example_Language>C++</Code_Example_Language>
							<Code_Block><![CDATA[#include <sys/types.h>
			]]><![CDATA[		#include <sys/stat.h>
					int]]><![CDATA[ main(argc,argv){
					  struct ]]><![CDATA[stat *sb;
					  time_t timer;
	]]><![CDATA[				  lstat("bar.sh",sb);
					 ]]><![CDATA[ printf("%d\n",sb->st_ctime);
		]]><![CDATA[			  switch(sb->st_ctime % 2){
	]]><![CDATA[				    case 0: printf("One opti]]><![CDATA[on\n");break;
					    case 1: p]]><![CDATA[rintf("another option\n");break;]]><![CDATA[
					    default: printf("huh\n]]><![CDATA[");break;
					  }
					  return]]><![CDATA[ 0;
					}]]></Code_Block>
						</Example_Code_Block>
					</Example_Block>
				</Example_Code>
			</Demonstrative_Example>
			<Context_Notes>This issue is particularly important in the case of switch statements that involve
				fall-through style case statements -- ie., those which do not end with break. If the variable
				which we are switching on change in the course of execution, the actions carried out may place the
				state of the process in a contradictory state or even result in memory corruption. For this
				reason, it is important to ensure that all variables involved in switch statements are locked
				before the statement starts and are unlocked when the statement ends. </Context_Notes>
				<Relationships>
				<Relationship>
						<Relationship_Views>
							<Relationship_View_ID Ordinal="Primary">1000</Relationship_View_ID>
						</Relationship_Views>
						<Relationship_Type>Weakness</Relationship_Type>
					<Relationship_Nature>ChildOf</Relationship_Nature>
					<Relationship_Target_ID>362</Relationship_Target_ID>
				</Relationship>
				<Relationship>
						<Relationship_Views>
							<Relationship_View_ID>1000</Relationship_View_ID>
						</Relationship_Views>
						<Relationship_Type>Weakness</Relationship_Type>
					<Relationship_Nature>PeerOf</Relationship_Nature>
					<Relationship_Target_ID>364</Relationship_Target_ID>
				</Relationship>
				<Relationship>
						<Relationship_Views>
							<Relationship_View_ID>1000</Relationship_View_ID>
						</Relationship_Views>
						<Relationship_Type>Weakness</Relationship_Type>
					<Relationship_Nature>PeerOf</Relationship_Nature>
					<Relationship_Target_ID>366</Relationship_Target_ID>
				</Relationship>
				</Relationships>
			<Source_Taxonomy Source_Taxonomy_Name="CLASP">
				<Original_Node_Name>Race condition in switch</Original_Node_Name>
			</Source_Taxonomy>
			<Applicable_Platforms>
				<Platform>C</Platform>
				<Platform>C++</Platform>
				<Platform>Java</Platform>
				<Platform>.NET</Platform>
			</Applicable_Platforms>
		</Common_Attributes>
	</Weakness>
                    <Weakness Weakness_ID="366" Weakness_Name="Race Condition within a Thread" Weakness_Abstraction="Base" Weakness_Status="Draft">
		<Common_Attributes>
			<Description>
				<Description_Summary>If two threads of execution use a resource simultaneously, there exists the possibility
				that resources may be used while invalid, in turn making the state of execution undefined.</Description_Summary>
			</Description>
			<Likelihood_of_Exploit>Medium</Likelihood_of_Exploit>
			<Affected_Resource>System Process</Affected_Resource>
			<Common_Consequences>
				<Common_Consequence>Integrity: The main problem is that -- if a lock is overcome -- data could be
					altered in a bad state.</Common_Consequence>
			</Common_Consequences>
			<Potential_Mitigations>
				<Mitigation>Design: Use locking functionality. This is the recommended solution. Implement some
					form of locking mechanism around code which alters or reads persistent data in a
					multi-threaded environment.</Mitigation>
				<Mitigation>Design: Create resource-locking sanity checks. If no inherent locking mechanisms
					exist, use flags and signals to enforce your own blocking scheme when resources are being used
					by other threads of execution.</Mitigation>
			</Potential_Mitigations>
			<Demonstrative_Example>
				<Example_Code>
					<Example_Block>
						<Example_Code_Block>
							<Code_Example_Language>C</Code_Example_Language>
							<Code_Example_Language>C++</Code_Example_Language>
							<Code_Block><![CDATA[int foo = 0;
					int storenum]]><![CDATA[(int num) { 
					  static int c]]><![CDATA[ounter = 0; 
					  counter++; 
]]><![CDATA[					  if (num > foo) foo = num;]]><![CDATA[ return foo; 
					}]]></Code_Block>
						</Example_Code_Block>
					</Example_Block>
					<Example_Block>
						<Example_Code_Block>
							<Code_Example_Language>Java</Code_Example_Language>
							<Code_Block><![CDATA[public classRace {
					  stat]]><![CDATA[ic int foo = 0; 
					  public s]]><![CDATA[tatic void main() { 
					    ne]]><![CDATA[w Threader().start(); foo = 1; 
]]><![CDATA[					  }
					  public static cl]]><![CDATA[ass Threader extends Thread { 
	]]><![CDATA[				    public void run() {
				]]><![CDATA[	      System.out.println(foo); ]]><![CDATA[
					    } 
					  } 
					}]]></Code_Block>
						</Example_Code_Block>
					</Example_Block>
				</Example_Code>
			</Demonstrative_Example>
				<Relationships>
				<Relationship>
						<Relationship_Views>
							<Relationship_View_ID Ordinal="Primary">1000</Relationship_View_ID>
						</Relationship_Views>
						<Relationship_Type>Weakness</Relationship_Type>
					<Relationship_Nature>ChildOf</Relationship_Nature>
					<Relationship_Target_ID>362</Relationship_Target_ID>
				</Relationship>
				<Relationship>
						<Relationship_Views>
							<Relationship_View_ID>1000</Relationship_View_ID>
						</Relationship_Views>
						<Relationship_Type>Category</Relationship_Type>
					<Relationship_Nature>ChildOf</Relationship_Nature>
					<Relationship_Target_ID>557</Relationship_Target_ID>
				</Relationship>
				<Relationship>
						<Relationship_Views>
							<Relationship_View_ID Ordinal="Primary">631</Relationship_View_ID>
						</Relationship_Views>
						<Relationship_Type>Category</Relationship_Type>
					<Relationship_Nature>ChildOf</Relationship_Nature>
					<Relationship_Target_ID>634</Relationship_Target_ID>
				</Relationship>
				</Relationships>
			<Source_Taxonomy Source_Taxonomy_Name="CLASP">
				<Original_Node_Name>Race condition within a thread</Original_Node_Name>
			</Source_Taxonomy>
			<Applicable_Platforms>
				<Platform>C</Platform>
				<Platform>C++</Platform>
				<Platform>Java</Platform>
				<Platform>.NET</Platform>
			</Applicable_Platforms>
			<Related_Attack_Patterns>
				<Related_Attack_Pattern>
					<CAPEC_ID>26<!--Leveraging Race Conditions--></CAPEC_ID>
				</Related_Attack_Pattern>
				<Related_Attack_Pattern>
					<CAPEC_ID>29<!--Leveraging Time-of-Check and Time-of-Use (TOCTOU) Race Conditions--></CAPEC_ID>
				</Related_Attack_Pattern>
			</Related_Attack_Patterns>
		</Common_Attributes>
	</Weakness>
                    <Weakness Weakness_ID="374" Weakness_Name="Mutable Objects Passed by Reference" Weakness_Abstraction="Base" Weakness_Status="Draft">
		<Common_Attributes>
			<Description>
				<Description_Summary>Sending non-cloned mutable data as an argument may result in that data being
				altered or deleted by the called function, thereby putting the calling function into an
				undefined state.</Description_Summary>
			</Description>
			<Likelihood_of_Exploit>Medium</Likelihood_of_Exploit>
			<Common_Consequences>
				<Common_Consequence>Integrity: Potentially data could be tampered with by another
					function which should not have been tampered with.</Common_Consequence>
			</Common_Consequences>
			<Potential_Mitigations>
				<Mitigation>Implementation: Pass in data which should not be altered as constant or
					immutable.</Mitigation>
				<Mitigation>Implementation: Clone all mutable data before returning references to it.
					This is the preferred mitigation. This way -- regardless of what changes are made to
					the data -- a valid copy is retained for use by the class.</Mitigation>
			</Potential_Mitigations>
			<Demonstrative_Example>
				<Example_Code>
					<Example_Block>
						<Example_Code_Block>
							<Code_Example_Language>C</Code_Example_Language>
							<Code_Example_Language>C++</Code_Example_Language>
							<Code_Block><![CDATA[private: in]]><![CDATA[t foo. complexType bar; 
					St]]><![CDATA[ring baz; otherClass externalCla]]><![CDATA[ss; 
					public: void doStuff()]]><![CDATA[ { 
					  externalClass.doOther]]><![CDATA[Stuff(foo, bar, baz) 
					}]]></Code_Block>
						</Example_Code_Block>
					</Example_Block>
					<PostText>In this example, bar and baz will be passed by reference to doOtherStuff()
						which may change them.</PostText>
				</Example_Code>
			</Demonstrative_Example>
			<Context_Notes>In situations where unknown code is called with references to mutable data,
				this external code may possibly make changes to the data sent. If this data was not
				previously cloned, you will be left with modified data which may, or may not, be valid
				in the context of execution.</Context_Notes>
				<Relationships>
				<Relationship>
						<Relationship_Views>
							<Relationship_View_ID>1000</Relationship_View_ID>
						</Relationship_Views>
						<Relationship_Type>Category</Relationship_Type>
					<Relationship_Nature>ChildOf</Relationship_Nature>
					<Relationship_Target_ID>371</Relationship_Target_ID>
				</Relationship>
				<Relationship>
						<Relationship_Views>
							<Relationship_View_ID Ordinal="Primary">1000</Relationship_View_ID>
						</Relationship_Views>
						<Relationship_Type>Weakness</Relationship_Type>
						<Relationship_Nature>ChildOf</Relationship_Nature>
					<Relationship_Target_ID>668</Relationship_Target_ID>
				</Relationship>
				</Relationships>
			<Source_Taxonomy Source_Taxonomy_Name="CLASP">
				<Original_Node_Name>Mutable objects passed by reference</Original_Node_Name>
			</Source_Taxonomy>
			<Applicable_Platforms>
				<Platform>C</Platform>
				<Platform>C++</Platform>
				<Platform>Java</Platform>
				<Platform>.NET</Platform>
			</Applicable_Platforms>
		</Common_Attributes>
	</Weakness>
                    <Weakness Weakness_ID="375" Weakness_Name="Passing Mutable Objects to an Untrusted Method" Weakness_Abstraction="Base" Weakness_Status="Draft">
		<Common_Attributes>
			<Description>
				<Description_Summary>Sending non-cloned mutable data as a return value may result in that data being
				altered or deleted by the calling function, thereby putting the class in an undefined
				state.</Description_Summary>
			</Description>
			<Likelihood_of_Exploit>Medium</Likelihood_of_Exploit>
			<Common_Consequences>
				<Common_Consequence>Access Control / Integrity: Potentially data could be tampered with
					by another function which should not have been tampered with.</Common_Consequence>
			</Common_Consequences>
			<Potential_Mitigations>
				<Mitigation>Implementation: Pass in data which should not be altered as constant or
					immutable.</Mitigation>
				<Mitigation>Implementation: Clone all mutable data before returning references to it.
					This is the preferred mitigation. This way, regardless of what changes are made to
					the data, a valid copy is retained for use by the class.</Mitigation>
			</Potential_Mitigations>
			<Demonstrative_Example>
				<Example_Code>
					<Example_Block>
						<Example_Code_Block>
							<Code_Example_Language>C</Code_Example_Language>
							<Code_Example_Language>C++</Code_Example_Language>
							<Code_Block><![CDATA[private]]><![CDATA[: externalClass foo; 
					publi]]><![CDATA[c: void doStuff() {
					  //../]]><![CDATA[/Modify foo 
					  return foo; ]]><![CDATA[
					}]]></Code_Block>
						</Example_Code_Block>
					</Example_Block>
					<Example_Block>
						<Example_Code_Block>
							<Code_Example_Language>Java</Code_Example_Language>
							<Code_Block><![CDATA[public clas]]><![CDATA[s foo {
					private externalCla]]><![CDATA[ss bar = new externalClass(); 
	]]><![CDATA[				public doStuff(...){ 
					 ]]><![CDATA[ //..//Modify bar 
					  return]]><![CDATA[ bar; 
					}]]></Code_Block>
						</Example_Code_Block>
					</Example_Block>
				</Example_Code>
			</Demonstrative_Example>
			<Context_Notes>In situations where functions return references to mutable data, it is
				possible that this external code, which called the function, may make changes to the
				data sent. If this data was not previously cloned, you will be left with modified data
				which may, or may not, be valid in the context of the class in question.</Context_Notes>
				<Relationships>
				<Relationship>
						<Relationship_Views>
							<Relationship_View_ID>1000</Relationship_View_ID>
						</Relationship_Views>
						<Relationship_Type>Category</Relationship_Type>
					<Relationship_Nature>ChildOf</Relationship_Nature>
					<Relationship_Target_ID>371</Relationship_Target_ID>
				</Relationship>
				<Relationship>
						<Relationship_Views>
							<Relationship_View_ID Ordinal="Primary">1000</Relationship_View_ID>
						</Relationship_Views>
						<Relationship_Type>Weakness</Relationship_Type>
						<Relationship_Nature>ChildOf</Relationship_Nature>
						<Relationship_Target_ID>668</Relationship_Target_ID>
				</Relationship>
				</Relationships>
			<Source_Taxonomy Source_Taxonomy_Name="CLASP">
				<Original_Node_Name>Passing mutable objects to an untrusted method</Original_Node_Name>
			</Source_Taxonomy>
			<Applicable_Platforms>
				<Platform>C</Platform>
				<Platform>C++</Platform>
				<Platform>Java</Platform>
				<Platform>.NET</Platform>
			</Applicable_Platforms>
		</Common_Attributes>
	</Weakness>
                    <Weakness Weakness_ID="387" Weakness_Name="Signal Errors" Weakness_Abstraction="Class" Weakness_Status="Incomplete">
		<Common_Attributes>
			<Description>
				<Description_Summary>The software does not properly handle or manage a signal.</Description_Summary>
			</Description>
			<Affected_Resource>System Process</Affected_Resource>
			<Observed_Examples>
				<Observed_Example>
					<Observed_Example_Reference>CVE-2002-2039</Observed_Example_Reference>
					<Observed_Example_Description>unhandled SIGSERV signal allows core dump</Observed_Example_Description>
				</Observed_Example>
				<Observed_Example>
					<Observed_Example_Reference>CVE-1999-1224</Observed_Example_Reference>
					<Observed_Example_Description>SIGABRT (abort) signal not properly handled, causing core dump.</Observed_Example_Description>
				</Observed_Example>
				<Observed_Example>
					<Observed_Example_Reference>CVE-2002-2039</Observed_Example_Reference>
					<Observed_Example_Description>SIGSERV (invalid memory reference) signal causes core dump.</Observed_Example_Description>
		