Goal Reached Thanks to every supporter — we hit 100%!

Goal: 1000 CNY · Raised: 1000 CNY

100.0%

CWE-135 (多字节字符串长度的计算不正确) — Vulnerability Class 1

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.

MITRE CWE Description
The product does not correctly calculate the length of strings that can contain wide or multi-byte characters.
Common Consequences (3)
Integrity, Confidentiality, AvailabilityExecute Unauthorized Code or Commands
This weakness may lead to a buffer overflow. Buffer overflows often can be used to execute arbitrary code, which is usually outside the scope of a program's implicit security policy. This can often be used to subvert any other security service.
Availability, ConfidentialityRead Memory, DoS: Crash, Exit, or Restart, DoS: Resource Consumption (CPU), DoS: Resource Consumption (Memory)
Out of bounds memory access will very likely result in the corruption of relevant memory, and perhaps instructions, possibly leading to a crash. Other attacks leading to lack of availability are possible, including putting the program into an infinite loop.
ConfidentialityRead Memory
In the case of an out-of-bounds read, the attacker may have access to sensitive information. If the sensitive information contains system details, such as the current buffer's position in memory, this knowledge can be used to craft further attacks, possibly with more severe consequences.
Mitigations (2)
ImplementationAlways verify the length of the string unit character.
ImplementationUse length computing functions (e.g. strlen, wcslen, etc.) appropriately with their equivalent type (e.g.: byte, wchar_t, etc.)
Examples (1)
The following example would be exploitable if any of the commented incorrect malloc calls were used.
#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 */ newStrin
Bad · C
Strlen() output: 0 Wcslen() output: 53
Result
CVE IDTitleCVSSSeverityPublished
CVE-2026-0810 Gix-date: gix-date: undefined behavior due to invalid string generation — gitoxide 7.1 High2026-01-26

Vulnerabilities classified as CWE-135 (多字节字符串长度的计算不正确) represent 1 CVEs. The CWE taxonomy describes the weakness; review individual CVEs for product-specific impact.