memset is called with a length of zero, its last two arguments swapped

tx0/cpp:memset-swappeddefaultwarningreliability/memory-safetydepth fastbug

What it finds

memset(p, n, 0): the length is zero, so nothing is written. The value and the length were swapped: memset(p, 0, n) was meant.

The function must be the C library's, and the length the literal 0 with a value that is not one. A fix that swaps the two is offered, but not applied without asking, since it changes what the program does.

From the rule's source, memset_swapped.rs.

Turn it on, off or suppress it

The rule runs in every tier. To turn it off for a project, set its level in tx0.toml:

tx0.toml
[rules]
"tx0/cpp:memset-swapped" = "off"

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:memset-swapped] reason="..."

tx0 explain tx0/cpp:memset-swapped shows the same in the terminal. Found a false positive? Report it.