open is asked to create a file but is not given the permissions for it
What it finds
open(path, O_WRONLY | O_CREAT): with O_CREAT or O_TMPFILE, open reads a third argument for the permissions of the new file; without one it takes whatever is on the stack or in a register, and the file gets arbitrary permissions.
From the rule's source, open_create_without_mode.rs.
#include <fcntl.h> int make(const char *path){ int a = open(path, O_WRONLY | O_CREAT);tx0 reports: open may create the file but is not given its permissions int b = open(path, O_WRONLY | O_CREAT, 0644); int c = open(path, O_RDONLY); return a + b + c;} 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:open-create-without-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:open-create-without-mode] reason="..."tx0 explain tx0/c:open-create-without-mode shows the same in the terminal. Found a false positive? Report it.