[tor-commits] [tor/release-0.2.3] Coverity 709056: Check return value on fputs in tor-gencert

arma at torproject.org arma at torproject.org
Tue Jul 31 09:13:20 UTC 2012


commit d32f5081e1c41324a3464c30c487c6ef57a333d1
Author: Nick Mathewson <nickm at torproject.org>
Date:   Mon Jul 16 11:38:39 2012 -0400

    Coverity 709056: Check return value on fputs in tor-gencert
---
 changes/cov709056       |    4 ++++
 src/tools/tor-gencert.c |    7 ++++++-
 2 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/changes/cov709056 b/changes/cov709056
new file mode 100644
index 0000000..64a75ad
--- /dev/null
+++ b/changes/cov709056
@@ -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.
+
diff --git a/src/tools/tor-gencert.c b/src/tools/tor-gencert.c
index a8ffc07..38b2101 100644
--- a/src/tools/tor-gencert.c
+++ b/src/tools/tor-gencert.c
@@ -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;
 }





More information about the tor-commits mailing list