]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Check strftime() return in tortls.c
authorAndrea Shepard <andrea@torproject.org>
Wed, 19 Mar 2014 18:22:11 +0000 (11:22 -0700)
committerNick Mathewson <nickm@torproject.org>
Mon, 31 Mar 2014 15:27:08 +0000 (11:27 -0400)
src/common/tortls.c

index 315a767e9ead38eac3290187bf0d3c70b4e4fdeb..50ae8afb1e0f808510a43edaf18f0f1efab129a9 100644 (file)
@@ -2311,6 +2311,7 @@ log_cert_lifetime(int severity, const X509 *cert, const char *problem)
   char mytime[33];
   time_t now = time(NULL);
   struct tm tm;
+  size_t n;
 
   if (problem)
     tor_log(severity, LD_GENERAL,
@@ -2336,11 +2337,17 @@ log_cert_lifetime(int severity, const X509 *cert, const char *problem)
   BIO_get_mem_ptr(bio, &buf);
   s2 = tor_strndup(buf->data, buf->length);
 
-  strftime(mytime, 32, "%b %d %H:%M:%S %Y UTC", tor_gmtime_r(&now, &tm));
-
-  tor_log(severity, LD_GENERAL,
-      "(certificate lifetime runs from %s through %s. Your time is %s.)",
-      s1,s2,mytime);
+  n = strftime(mytime, 32, "%b %d %H:%M:%S %Y UTC", tor_gmtime_r(&now, &tm));
+  if (n > 0) {
+    tor_log(severity, LD_GENERAL,
+        "(certificate lifetime runs from %s through %s. Your time is %s.)",
+        s1,s2,mytime);
+  } else {
+    tor_log(severity, LD_GENERAL,
+        "(certificate lifetime runs from %s through %s. "
+        "Couldn't get your time.)",
+        s1, s2);
+  }
 
  end:
   /* Not expected to get invoked */