title: Tainted string in C
body: <p>I'm running Coverity tool in my file operation function and getting the following error.</p>
  
  <p>As you can see below, I'm using an snprintf() before passing this variable in question to the line number shown in the error message. I guess that some sanitization of the string has to be done as a part of that snprintf(). But still the warning is shown.</p>
  
  <pre><code>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");
  </code></pre>
  
  <p>Any help would be highly appreciated.</p>