我在我的文件操作函数中运行 Coverity 工具并收到以下错误。
正如您在下面看到的,在将这个有问题的变量传递给错误消息中显示的行号之前,我使用了一个 snprintf()。我想必须对字符串进行一些清理,作为 snprintf() 的一部分。但仍然显示警告。
Error:TAINTED_STRING (TAINTED string "fn" was passed to a tainted string sink content.) [coverity]
char fn[100]; int id = 0;
char* id_str = getenv("ID");
if (id_str) {
id = atoi(id_str);
}
memset(fn, '\0', sizeof(fn));
snprintf(fn, 100, LOG_FILE, id);
if(fn[100-1] != '\0') {
fn[100-1] = '\0';
}
log_fp = fopen (fn, "a");
任何帮助将不胜感激。