Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Integer overflow is undefined behavior. This means that implementations have a great deal of latitude in how they deal with signed integer overflow. An implementation that defines signed integer types as being modulo, for example, need not detect integer over-flow. Implementations may also trap on signed arithmetic overflows or simply assume that overflows will never happen and generate object code accordingly (see MSC15-C, “Do not depend on undefined behavior”). For these reasons, it is important to ensure that operations on signed integers do not result in signed overflow. Of particular importance, however, are operations on signed integer values that originate from untrusted sources and are used in any of the following ways: