sscanf copies a word of its input into a buffer with no limit on its length
What it finds
sscanf(line, "%s %d", name, &n): %s and %[ without a width copy a whole word of the input, so a destination smaller than the input string can overflow. Code that sizes the destination after the input is safe, which is why this is apart from scanf-unbounded-string; a width makes the limit visible either way.
From the rule's source, sscanf_unbounded_string.rs.
#include <stdio.h> void split(const char *line){ char word[64]; sscanf(line, "%s", word);tx0 reports: %s lets sscanf copy a word of any length sscanf(line, "%63s", word);} Turn it on, off or suppress it
The rule runs from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/c:sscanf-unbounded-string" = "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:sscanf-unbounded-string] reason="..."tx0 explain tx0/c:sscanf-unbounded-string shows the same in the terminal. Found a false positive? Report it.