title: Possible security vulnerability from using fgets() and recommended solution?
body: <p>I'm using coverity's SA tool for errors. I'm getting a few errors due to the usage of fgets(). This is a snippet (SA errors shown as comments)-</p>
  
  <pre><code>FILE *fp;
  char my_pubkey[1024];
  
  fp = fopen("publickey.pub", "r");
  
  //tainted_string_argument: fgets taints variable my_pubkey.
  if (!fgets(my_pubkey, sizeof(my_pubkey), fp)) {
      printf("failure to read pub key file");
      goto error;
  }
  
  //tainted_string: Passing tainted string my_pubkey to a parameter that cannot accept a tainted format string.
  if (fprintf(fp, my_pubkey) != strlen(my_pubkey)) {
      printf ("failure to write pub key in key file");
      goto error; 
  }
  </code></pre>
  
  <p>In my investigation, some reports suggest using getline() instead, but is that really needed? If this is a valid issue, what can be the vulnerability? And what's the best solution?</p>
  
  <p>EDIT: If this is a false positive, why so? What can be an example of when it would be an actual issue?</p>