gets is called
What it finds
gets(buf) reads a line of any length into a buffer of fixed size, so any input longer than the buffer overwrites what follows it. No use of it is safe, and C11 removed it; fgets takes the size of the buffer.
Only the C library's gets counts: a file that declares its own, or defines a macro of the name, is left alone.
From the rule's source, gets.rs.
#include <stdio.h> int read_line(char *buf, int size){ if (gets(buf) == NULL)tx0 reports: gets cannot know the size of the buffer it fills return -1; return fgets(buf, size, stdin) != NULL;} 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:
[rules]
"tx0/c:gets" = "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/c:gets] reason="..."tx0 explain tx0/c:gets shows the same in the terminal. Found a false positive? Report it.