2 vulnerabilities classified as CWE-467 (在指针类型上使用sizeof()). AI Chinese analysis included.
CWE-467 represents a logical error where developers incorrectly apply the sizeof operator to a pointer variable rather than the underlying data structure it references. This weakness typically arises when programmers assume sizeof returns the size of the pointed-to array or object, leading to severe buffer overflows or underflows during memory allocation and copying operations. Attackers exploit this miscalculation by triggering out-of-bounds memory accesses, potentially achieving arbitrary code execution or causing application crashes through denial of service. To prevent this vulnerability, developers must explicitly pass the correct data type or array length to sizeof, ensuring the calculation reflects the actual memory footprint of the target data. Rigorous static analysis tools and code reviews are essential for identifying these subtle pointer arithmetic errors before deployment, thereby maintaining memory safety and application integrity.
double *foo; ... foo = (double *)malloc(sizeof(foo));double *foo; ... foo = (double *)malloc(sizeof(*foo));/* Ignore CWE-259 (hard-coded password) and CWE-309 (use of password system for authentication) for this example. */ char *username = "admin"; char *pass = "password"; int AuthenticateUser(char *inUser, char *inPass) { printf("Sizeof username = %d\n", sizeof(username)); printf("Sizeof pass = %d\n", sizeof(pass)); if (strncmp(username, inUser, sizeof(username))) { printf("Auth failure of username using sizeof\n"); return(AUTH_FAIL); } /* Because of CWE-467, the sizeof returns 4 on many platforms and architectures. */ if (! strncmp(pass, inPass, sizeof(pass))) { printf("Auth success of password pass5 passABCDEFGH passWORD| CVE ID | Title | CVSS | Severity | Published |
|---|---|---|---|---|
| CVE-2025-33132 | Fixes to common vulnerabilities found in IBM Db2 High Performance Unload — DB2 High Performance Unload | 6.5 | Medium | 2025-10-27 |
| CVE-2020-1638 | Junos OS & Junos OS Evolved: A specific IPv4 packet can lead to FPC restart. — Junos OS | 7.5 | High | 2020-04-08 |
Vulnerabilities classified as CWE-467 (在指针类型上使用sizeof()) represent 2 CVEs. The CWE taxonomy describes the weakness; review individual CVEs for product-specific impact.