]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
tls-crypt: properly cast time_t to uint64_t
authorAntonio Quartulli <a@unstable.cc>
Wed, 31 Oct 2018 16:01:24 +0000 (00:01 +0800)
committerGert Doering <gert@greenie.muc.de>
Wed, 31 Oct 2018 16:52:46 +0000 (17:52 +0100)
The exact type of time_t is platform dependent and therefore
can't be assumed to be uint64_t all the time.

For example, on 32bit platforms, where time_t is defined as long
(32bit), the compiler will generate the following warning, due
to the arithmetic used in the macro:

tls_crypt.c:745:29: warning: shift count >= width of type
[-Wshift-count-overflow]

Force time_t to be parsed as uint64_t.

Reported-by: Arne Schwabe <arne@rfc2549.org>
Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20181031160124.26972-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg17868.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
src/openvpn/tls_crypt.c

index d70d0a6603c6e880350ec89363b01d442f9ade8a..c3ed2b93b3f084e3c8294cc710f0d8cc59866672 100644 (file)
@@ -742,7 +742,7 @@ tls_crypt_v2_write_client_key_file(const char *filename,
     }
     else
     {
-        int64_t timestamp = htonll(now);
+        int64_t timestamp = htonll((uint64_t)now);
         ASSERT(buf_write(&metadata, &TLS_CRYPT_METADATA_TYPE_TIMESTAMP, 1));
         ASSERT(buf_write(&metadata, &timestamp, sizeof(timestamp)));
     }