A string is copied or appended with a function that does not know the size of the destination

tx0/c:unbounded-string-copystrictwarningsecurity, cwe-120

What it finds

strcpy(dst, src) and strcat(dst, src) copy until the end of the source, however large the destination is; a longer source overwrites the memory after it. Functions that take the size, as snprintf or strlcpy, or a length checked before the copy, avoid that.

A copy of a string literal into an array the file declares with room for it is left alone.

From the rule's source, unbounded_string_copy.rs.

Example from the rule's tests
#include <string.h> void copy(char *dst, const char *src){  char small[8];  strcpy(dst, src);tx0 reports: strcpy does not know how large its destination is  strcat(dst, "!");tx0 reports: strcat does not know how large its destination is  strcpy(small, "fits");  strcpy(small, "does not fit");tx0 reports: strcpy does not know how large its destination is}
Highlighted lines are the ones tx0 reports, with its message under each; the other lines are left alone.

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/c:unbounded-string-copy" = "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/c:unbounded-string-copy] reason="..."

tx0 explain tx0/c:unbounded-string-copy shows the same in the terminal. Found a false positive? Report it.