JavaScript is not currently enabled, but is required for full CodeSonar manual search and browse functionality.
If you are viewing this file in your hub's Web GUI, enable JavaScript in your browser: you will also need it for GUI functionality.
If you opened this file directly from disk, your browser may be directly suppressing JavaScript functionality: certain browsers perform this suppression on local files (but not files delivered by web servers) for security reasons.
| CodeSonar® 9.2p0 | CONFIDENTIAL | CodeSecure Inc |
An allocation size used as an argument to an allocator function is based on unchecked multiplication, thus risking integer overflow and an unexpectedly small allocated block.
(Note: When multiplication overflow can affect size calculation for an operation other than memory allocation, warning class Multiplication Overflow of Size applies instead.)
In general, this class represents a superset of Integer Overflow of Allocation Size, except that the implicit multiplication in C++ new[] may trigger an Integer Overflow Of Allocation Size warning but will not trigger a Multiplication Overflow of Allocation Size warning.
| Class Name | Multiplication Overflow of Allocation Size | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Significance | security | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Mnemonic | ALLOC.SIZE.MULOFLOW | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Categories |
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Availability | Available for C and C++. |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Enabling | Checks for this warning class are
disabled by default. To enable them, add the following WARNING_FILTER
rule to the project configuration file.
WARNING_FILTER += allow class="Multiplication Overflow of Allocation Size" |
#include <stdlib.h>
int do_muloflow_alloc(int x, int y)
{
char *p = malloc(x*y); /* 'Multiplication Overflow of Allocation Size' warning issued here. */
/* 'Integer Overflow of Allocation Size' warning also issued */
int rv = 0;
if (p){
rv = 1;
free(p);
}
return rv;
}
Multiplication Overflow of Allocation Size warnings can be triggered by any function treated as an allocator by CodeSonar:
Note that classes Addition Overflow of Allocation Size, Multiplication Overflow of Allocation Size, Subtraction Underflow of Allocation Size and Truncation of Allocation Size all have the same set of triggering functions.
This is a "taint+dp" warning class: warnings of this class undergo a dedicated refinement phase that cannot be disabled. One consequence of this is that reporting exhibits some degree of unavoidable nondeterminism. If result stability is important to you, you may wish to avoid enabling this class.
In issuing a warning of this class, CodeSonar does not take into account any constraints on integer values that are imposed before the beginning of the warning's core path.
The following configuration file parameters affect checks for this warning class.
To report problems with this documentation, please visit https://support.codesecure.com/.