CVE-2024-46952: Integer Truncation Max Width Allocation

An integer truncation occurs when a 64-bit array element is assigned to a 32-bit integer. When this truncated value is subsequently used in a function call (such as a memory allocation size), it can result in allocating an undersized buffer, leading to an overflow. Ensure the variable is of an adequate type (e.g., `uint64_t`) and implement bounds checking on

Provally CuratedPublic repositoryHighMedium confidenceVerifiedApache-2.0c
greprules fetch cve-2024-46952-integer-truncation-max-width-allocation --engine opengrep

Description

An integer truncation occurs when a 64-bit array element is assigned to a 32-bit integer. When this truncated value is subsequently used in a function call (such as a memory allocation size), it can result in allocating an undersized buffer, leading to an overflow. Ensure the variable is of an adequate type (e.g., `uint64_t`) and implement bounds checking on

Detection target

Not provided

Recommended fix

Not provided

False-positive notes

Not provided

Community feedback

Sign in to report false positives, mark this rule useful, or suggest metadata improvements.