A string literal is passed where a function writes, as to strtok, mkstemp or the destination of strcpy
What it finds
mkstemp("/tmp/dataXXXXXX") or strtok("a,b,c", ","): these functions write into the string they are given, and a string literal may not be modified; it usually lives in read-only memory, so the program crashes, or literals that share storage change.
From the rule's source, literal_given_to_writing_function.rs.
#include <stdlib.h> int temp(void){ return mkstemp("/tmp/dataXXXXXX");tx0 reports: mkstemp writes into this string literal, which may not be modified} 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:literal-given-to-writing-function" = "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:literal-given-to-writing-function] reason="..."tx0 explain tx0/c:literal-given-to-writing-function shows the same in the terminal. Found a false positive? Report it.