Skip to contentSkip to conversation

CRL: use time_t instead of struct timespec to store last mtime

PATCH In review Antonio Quartulli 2 participants 2 messages Mar 16, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 CRL: use time_t instead of struct timespec to store last mtime

As of now, we store the last mtime for the CRL file in a timespec object. However we store seconds only and we ignore the subsecond field (this came into being because not all platforms have nanoseconds precision in timespec).

Given the above, we can safely replace the timespec object with a simple time_t.

---

Compiled tested on linux only as I can't build for windows in this very moment.

 src/openvpn/ssl.c         | 4 ++--
 src/openvpn/ssl_mbedtls.h | 2 +-
 src/openvpn/ssl_openssl.h | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)
src/openvpn/ssl.c +2 -2
index beee82f5..fca1e7c5 100644
@@ -571,12 +571,12 @@ tls_ctx_reload_crl(struct tls_root_ctx *ssl_ctx, const char *crl_file,
      * Note: Windows does not support tv_nsec.
      */
     if ((ssl_ctx->crl_last_size == crl_stat.st_size)
-        && (ssl_ctx->crl_last_mtime.tv_sec == crl_stat.st_mtime))
+        && (ssl_ctx->crl_last_mtime == crl_stat.st_mtime))
     {
         return;
     }
 
-    ssl_ctx->crl_last_mtime.tv_sec = crl_stat.st_mtime;
+    ssl_ctx->crl_last_mtime = crl_stat.st_mtime;
     ssl_ctx->crl_last_size = crl_stat.st_size;
     backend_tls_ctx_reload_crl(ssl_ctx, crl_file, crl_file_inline);
 }
src/openvpn/ssl_mbedtls.h +1 -1
index 1bc53ce8..d8f717ce 100644
@@ -74,7 +74,7 @@ struct tls_root_ctx {
     mbedtls_x509_crt *ca_chain;         /**< CA chain for remote verification */
     mbedtls_pk_context *priv_key;       /**< Local private key */
     mbedtls_x509_crl *crl;              /**< Certificate Revocation List */
-    struct timespec crl_last_mtime;     /**< CRL last modification time */
+    time_t crl_last_mtime;              /**< CRL last modification time */
     off_t crl_last_size;                /**< size of last loaded CRL */
 #if defined(ENABLE_PKCS11)
     mbedtls_pkcs11_context *priv_key_pkcs11;    /**< PKCS11 private key */
src/openvpn/ssl_openssl.h +1 -1
index c64c65f8..6ca4cb6d 100644
@@ -49,7 +49,7 @@
  */
 struct tls_root_ctx {
     SSL_CTX *ctx;
-    struct timespec crl_last_mtime;
+    time_t crl_last_mtime;
     off_t crl_last_size;
 };
 
Signature · 1 line
2.12.0
#1 lore raw

ACK, thanks. Tested on FreeBSD, unsurprisingly no problems.

Your patch has been applied to the master and release/2.4 branch.

commit f3705dd1e711ee9f8546b841e4b18e9e9a224975 (master) commit 633138564d611b5abeff232c89dccb1b86def449 (release/2.4)

Author: Antonio Quartulli
Date:   Thu Mar 16 16:21:17 2017 +0800
     CRL: use time_t instead of struct timespec to store last mtime

     Signed-off-by: Antonio Quartulli <[email protected]...>
     Acked-by: Gert Doering <[email protected]...>
     Message-Id: <[email protected]...>
     URL: http://www.mail-archive.com/search?l=mid&[email protected]...
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering