![]() SEI CERT C Coding Standard - Guidelines 08. SEI CERT C Coding Standard - Guidelines 04. SEI CERT Oracle Secure Coding Standard for Java - Guidelines 03. SFP Secondary Cluster: Glitch in Computation The two main view structures are Slices (flat lists) and Graphs (containing relationships between entries). View - a subset of CWE entries that provides a way of examining CWE content. To correct the situation the appropriate primitive type should be used, as in the example below, and/or provide some validation mechanism to ensure that the maximum value for the primitive type is not exceeded.Ĭategory - a CWE entry that contains a set of other entries that share a common characteristic.ĬERT C Secure Coding Standard (2008) Chapter 5 - Integers (INT)ĬERT C Secure Coding Standard (2008) Chapter 9 - Memory Management (MEM)ĬERT C++ Secure Coding Section 04 - Integers (INT)ĬERT C++ Secure Coding Section 08 - Memory Management (MEM) An integer overflow can lead to data corruption, unexpected behavior, infinite loops and system crashes. This creates a potential integer overflow if the value for the three monthly sales adds up to more than the maximum value for the short int primitive type. In C the short int primitive type has a maximum value of 32768. However, in this example the primitive type short int is used for both the monthly and the quarterly sales variables. QuarterRevenue = calculateRevenueForQuarter(quarterSold) Calculate the total revenue for the quarter Short quarterSold = JanSold + FebSold + MarSold Short MarSold = getMonthlySales(MAR) /* Get sales in March */ Short FebSold = getMonthlySales(FEB) /* Get sales in February */ Short JanSold = getMonthlySales(JAN) /* Get sales in January */ Variable for sales revenue for the quarter In addition, relationships such as PeerOf and CanAlsoBe are defined to show similar weaknesses that the user may want to explore. These relationships are defined as ChildOf, ParentOf, MemberOf and give insight to similar items that may exist at higher and lower levels of abstraction. ![]() ![]() This table shows the weaknesses and high level categories that are related to this weakness. Improper Restriction of Operations within the Bounds of a Memory Buffer Class level weaknesses typically describe issues in terms of 1 or 2 of the following dimensions: behavior, property, and resource. More specific than a Pillar Weakness, but more general than a Base Weakness. Insufficient Precision or Accuracy of a Real NumberĬlass - a weakness that is described in a very abstract fashion, typically independent of any specific language or technology. One solution is to use (2ll 1000000) 1000000 which forces the implicit conversion of the other terms. It doesnt matter that you are assigning the result of this expression to a different type. Base level weaknesses typically describe issues in terms of 2 or 3 of the following dimensions: behavior, property, technology, language, and resource. All the literals in (1000000 2) 1000000 are int types, and the compiler is warning you that this overflows the int on your platform. That is still mostly independent of a resource or technology, but with sufficient details to provide specific methods for detection and prevention. Chains can involve more than two weaknesses, and in some cases, they might have a tree-like structure. When this happens, CWE refers to X as "primary" to Y, and Y is "resultant" from X. One weakness, X, can directly create the conditions that are necessary to cause another weakness, Y, to enter a vulnerable condition. A Pillar is different from a Category as a Pillar is still technically a type of weakness that describes a mistake, while a Category represents a common characteristic used to group related things.Ĭhain - a Compound Element that is a sequence of two or more separate weaknesses that can be closely linked together within software. One solution is to use a wider data type, such as an int.Pillar - a weakness that is the most abstract type of weakness and represents a theme for all class/base/variant weaknesses related to it. main.go:2:17: constant 256 overflows byte If we use the standard loop idiom with a strict inequality, ![]() The Go Programming Language Specification: Arithmetic operators No exception is raised as a result of overflow. Where n is the bit width of the unsigned integer type.įor signed integers, the operations +, -, *, and << may legally overflowĪnd the resulting value exists and is deterministically definedīy the signed integer representation, the operation, and its operands. Therefore b <= 255 still holds and the loop restarts from 0.įor unsigned integer values, the operations +, -, *, and << are computed modulo 2 n, This overflows (since the maximum value for a byte is 255) and results in b = 0. Why does this loop run forever? var b byteĪfter the b = 255 iteration, b++ is executed.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |