1 vulnerabilities classified as CWE-135 (多字节字符串长度的计算不正确). AI Chinese analysis included.
CWE-135 represents a critical logic error where software fails to accurately determine the byte length of multi-byte or wide-character strings. This vulnerability typically arises when developers assume a one-to-one correspondence between character count and byte size, ignoring the variable-length encoding schemes used by character sets like UTF-8 or UTF-16. Attackers exploit this miscalculation to trigger buffer overflows or off-by-one errors, potentially allowing arbitrary code execution or denial of service by writing beyond allocated memory boundaries. To prevent such exploits, developers must utilize robust string handling libraries that explicitly account for multi-byte encodings. Implementing strict input validation and employing functions that correctly calculate byte lengths rather than character counts ensures memory safety. Regular static analysis and thorough testing with diverse character sets further mitigate the risk of these subtle yet dangerous calculation errors.
#include <stdio.h> #include <strings.h> #include <wchar.h> int main() { wchar_t wideString[] = L"The spazzy orange tiger jumped " \ "over the tawny jaguar."; wchar_t *newString; printf("Strlen() output: %d\nWcslen() output: %d\n", strlen(wideString), wcslen(wideString)); /* Wrong because the number of chars in a string isn't related to its length in bytes // newString = (wchar_t *) malloc(strlen(wideString)); */ /* Wrong because wide characters aren't 1 byte long! // newString = (wchar_t *) malloc(wcslen(wideString)); */ /* Wrong because wcslen does not include the terminating null */ newStrinStrlen() output: 0 Wcslen() output: 53| CVE ID | Title | CVSS | Severity | Published |
|---|---|---|---|---|
| CVE-2026-0810 | Gix-date: gix-date: undefined behavior due to invalid string generation — gitoxide | 7.1 | High | 2026-01-26 |
Vulnerabilities classified as CWE-135 (多字节字符串长度的计算不正确) represent 1 CVEs. The CWE taxonomy describes the weakness; review individual CVEs for product-specific impact.