...
The Mozilla Foundation Security Advisory 2007-01 describes a heap buffer overflow vulnerability in the Mozilla Scalable Vector Graphics (SVG) viewer resulting from an unsigned integer wrap during the multiplication of the signed int
value pen->num_vertices
and the size_t
value sizeof(cairo_pen_vertex_t)
[VU#551436]. The signed int
operand is converted to size_t
prior to the multiplication operation so that the multiplication takes place between two size_t
integers, which are unsigned. (see See INT02-C. Understand integer conversion rules.).
Code Block | ||||
---|---|---|---|---|
| ||||
pen->num_vertices = _cairo_pen_vertices_needed( gstate->tolerance, radius, &gstate->ctm ); pen->vertices = malloc( pen->num_vertices * sizeof(cairo_pen_vertex_t) ); |
...
INT30-C-EX3. The left-shift operator takes two operands of integer type. Unsigned left shift <<
can exhibit modulo behavior (wrapping). This exception is provided because of common usage, because this behavior is usually expected by the programmer, and because the behavior is well defined. For examples of usage of the left-shift operator, see INT34-C. Do not shift an expression by a negative number of bits or by greater than or equal to the number of bits that exist in the operand.
...
CVE-2009-1385 results from a violation of this rule. The value performs an unchecked subtraction on the length
of a buffer and then adds those many bytes of data to another buffer [xorl 2009]. This can cause a buffer overflow, which allows an attacker to execute arbitrary code.
A Linux kernel Kernel vmsplice exploit, described by Rafal Wojtczuk [Wojtczuk 2008], documents a vulnerability and exploit arising from a buffer overflow (caused by unsigned integer wrapping).
...
...