[Spice-devel] [PATCH spice-server] reds: Do not get time if not needed

Frediano Ziglio fziglio at redhat.com
Wed Nov 22 11:53:55 UTC 2017


Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
---
 server/reds.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/server/reds.c b/server/reds.c
index 2b43bc0d..8bda85c7 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -2036,11 +2036,8 @@ static void reds_handle_ticket(void *opaque)
     RedLinkInfo *link = (RedLinkInfo *)opaque;
     RedsState *reds = link->reds;
     char *password;
-    time_t ltime;
     int password_size;
 
-    //todo: use monotonic time
-    time(&ltime);
     if (RSA_size(link->tiTicketing.rsa) < SPICE_MAX_PASSWORD_LENGTH) {
         spice_warning("RSA modulus size is smaller than SPICE_MAX_PASSWORD_LENGTH (%d < %d), "
                       "SPICE ticket sent from client may be truncated",
@@ -2061,7 +2058,8 @@ static void reds_handle_ticket(void *opaque)
     password[password_size] = '\0';
 
     if (reds->config->ticketing_enabled && !link->skip_auth) {
-        int expired =  reds->config->taTicket.expiration_time < ltime;
+        time_t ltime;
+        bool expired;
 
         if (strlen(reds->config->taTicket.password) == 0) {
             spice_warning("Ticketing is enabled, but no password is set. "
@@ -2069,6 +2067,10 @@ static void reds_handle_ticket(void *opaque)
             goto error;
         }
 
+        //todo: use monotonic time
+        time(&ltime);
+        expired =  reds->config->taTicket.expiration_time < ltime;
+
         if (expired) {
             spice_warning("Ticket has expired");
             goto error;
-- 
2.14.3



More information about the Spice-devel mailing list