[Spice-commits] server/reds.c

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Oct 30 10:18:49 UTC 2018


 server/reds.c |    5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

New commits:
commit 585b534c0c796663a5744811a4d8e6e60fd51483
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Wed Sep 5 09:45:48 2018 +0100

    reds: Use monotonic time for ticket expiration
    
    Avoid time adjustment issues.
    For instance ticket validity can change when daylight time changes.
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Lukáš Hrázký <lhrazky at redhat.com>

diff --git a/server/reds.c b/server/reds.c
index d3b8e839..575470e4 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -2098,8 +2098,7 @@ static void reds_handle_ticket(void *opaque)
             goto error;
         }
 
-        //todo: use monotonic time
-        time(&ltime);
+        ltime = spice_get_monotonic_time_ns() / NSEC_PER_SEC;
         expired = (reds->config->taTicket.expiration_time < ltime);
 
         if (expired) {
@@ -3832,7 +3831,7 @@ SPICE_GNUC_VISIBLE int spice_server_set_ticket(SpiceServer *reds,
     if (lifetime == 0) {
         reds->config->taTicket.expiration_time = INT_MAX;
     } else {
-        time_t now = time(NULL);
+        time_t now = spice_get_monotonic_time_ns() / NSEC_PER_SEC;
         reds->config->taTicket.expiration_time = now + lifetime;
     }
     if (passwd != NULL) {


More information about the Spice-commits mailing list