CWE - 135 : Incorrect Calculation of Multi-Byte String Length
|
CWE Definition
|
http://cwe.mitre.org/data/definitions/135.html
|
|
Number of vulnerabilities:
|
0
|
|
Description
|
The software does not correctly calculate the length of strings
that can contain wide or multi-byte characters. |
|
Background Details
|
|
|
Other 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. |
|
|
Warning! CWE definitions are provided as a quick reference. They are
not complete and may not be up to date!
You must visit
http://cwe.mitre.org/ for a complete list of CWE entries
and for more details.