Coverity 709056: Check return value on fputs in tor-gencert

This commit is contained in:
Nick Mathewson 2012-07-16 11:38:39 -04:00
parent 9ad5b25930
commit d32f5081e1
2 changed files with 10 additions and 1 deletions

4
changes/cov709056 Normal file
View File

@ -0,0 +1,4 @@
o Minor bugfixes:
- Check return value of fputs() when writing authority certificate
file. Fixes Coverity issue 709056; bugfix on 0.2.0.1-alpha.

View File

@ -497,7 +497,12 @@ generate_certificate(void)
return 1;
}
fputs(buf, f);
if (fputs(buf, f) < 0) {
log_err(LD_GENERAL, "Couldn't write to %s: %s",
certificate_file, strerror(errno));
fclose(f);
return 1;
}
fclose(f);
return 0;
}