A stream is opened with a mode string that the C library does not define
What it finds
fopen(path, "rw") or fopen(path, "+r"): a mode must start with r, w or a, optionally followed by + and the letters the C library accepts after it, such as b, x and glibc's e, m and c. Anything else is undefined; glibc fails or silently reads the first letter only.
The mode must be a string literal given to the C library's fopen, freopen or fdopen. A ,ccs= suffix, which Windows accepts, is allowed.
From the rule's source, invalid_open_mode.rs.
#include <stdio.h> void open_all(const char *path){ FILE *a = fopen(path, "rw");tx0 reports: is not a mode the C library defines FILE *b = fopen(path, "+r");tx0 reports: is not a mode FILE *c = fopen(path, "r+b"); FILE *d = fopen(path, "we"); fclose(a); fclose(b); fclose(c); fclose(d);} 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:invalid-open-mode" = "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:invalid-open-mode] reason="..."tx0 explain tx0/c:invalid-open-mode shows the same in the terminal. Found a false positive? Report it.