diff options
author | Andrea Shepard <andrea@torproject.org> | 2014-03-19 11:22:11 -0700 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2014-03-31 11:27:08 -0400 |
commit | dea81901114f2bc67cdc9d9072fbfe1b6797920e (patch) | |
tree | b755fb5534c411030127c32b1a121c3def80f152 /src/common | |
parent | 0938c20fa3b44a09d20ba2eb05775b0c46d39129 (diff) | |
download | tor-dea81901114f2bc67cdc9d9072fbfe1b6797920e.tar.gz tor-dea81901114f2bc67cdc9d9072fbfe1b6797920e.zip |
Check strftime() return in tortls.c
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/tortls.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/common/tortls.c b/src/common/tortls.c index 315a767e9e..50ae8afb1e 100644 --- a/src/common/tortls.c +++ b/src/common/tortls.c @@ -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 */ |