CWEweakness
CWE-467 Use of sizeof() on a Pointer Type
High
Official page ↗
- Abstraction
- Variant
- Structure
- Simple
- Status
- Draft
- Likelihood of exploit
- High
- Languages
- C, C++
- CWE version
- 5.0
Description
The code calls sizeof() on a pointer type, when the programmer intended to determine the size of the data that is being pointed to.
Common consequences
• Integrity, Confidentiality: Modify Memory, Read Memory — This error can often cause one to allocate a buffer that is much smaller than what is needed, leading to resultant weaknesses such as buffer overflows.
Potential mitigations
• [Implementation] Use expressions such as "sizeof(*pointer)" instead of "sizeof(pointer)", unless you intend to run sizeof() on a pointer type to gain some platform independence or if you are allocating a variable on the stack.
Detection methods
• Automated Static Analysis: Automated static analysis, commonly referred to as Static Application Security Testing (SAST), can find some instances of this weakness by analyzing source code (or binary/compiled code) without having to execute it. Typically, this is done by building a model of data flow and control flow, then searching for potentially-vulnerable patterns that connect "sources" (origins of input) with "sinks" (destinations where the data interacts with external components, a lower layer such as the OS, etc.)
Observed examples
• CVE-2025-33132: Database utility uses sizeof() on a pointer type, leading to incorrect size calculation and a crash.
Related
Observed example · CVE (1)
- CVE-2025-33132 IBM DB2 High Performance Unload 6.1.0.3, 5.1.0.1, 6.1.0.2, 6.5, 6.5.0.0 IF1, 6.1.0.1, 6.1, and 5.1 could allow an authenticated user to… vulnerability
Child of · CWE (1)
- CWE-131 Incorrect Calculation of Buffer Size weakness
Referenced by CVE · weakness (4)
- CVE-2026-52761 ModSecurity is an open source, cross platform web application firewall (WAF) engine for Apache, IIS and Nginx. vulnerability
- CVE-2025-33132 IBM DB2 High Performance Unload 6.1.0.3, 5.1.0.1, 6.1.0.2, 6.5, 6.5.0.0 IF1, 6.1.0.1, 6.1, and 5.1 could allow an authenticated user to… vulnerability
- CVE-2021-47456 In the Linux kernel, the following vulnerability has been resolved: can: peak_pci: peak_pci_remove(): fix UAF When remove the module… vulnerability
- CVE-2020-1638 The FPC (Flexible PIC Concentrator) of Juniper Networks Junos OS and Junos OS Evolved may restart after processing a specific IPv4 packet. vulnerability
Referenced by CWE · has member (1)
- CWE-884 CWE Cross-section view