The size given to malloc or realloc is a product that may overflow unchecked

tx0/cpp:allocation-size-productstrictwarningreliability/arithmeticdepth fastsecurity, cwe-190

What it finds

malloc(count * size): if the product wraps around, a small block is allocated and the code that fills it writes far past its end. calloc(count, size) checks the multiplication, and so does an explicit test before it.

A product of constants and sizeof only is left alone.

From the rule's source, allocation_size_product.rs.

Turn it on, off or suppress it

The rule runs from the strict tier up. To turn it on in a lower tier, give it a level in tx0.toml:

tx0.toml
[rules]
"tx0/cpp:allocation-size-product" = "warning"

To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:

// tx0: ignore[tx0/cpp:allocation-size-product] reason="..."

tx0 explain tx0/cpp:allocation-size-product shows the same in the terminal. Found a false positive? Report it.