[PATCH 4/9] Move ticket decryption to helper function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



---
 server/reds.c | 23 +++++++++++++++++------
 1 file changed, 17 insertions(+), 6 deletions(-)

diff --git a/server/reds.c b/server/reds.c
index 19a3298..f45092b 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -1843,15 +1843,11 @@ static void reds_handle_link(RedLinkInfo *link)
     }
 }
 
-static void reds_handle_ticket(void *opaque)
+static char *reds_get_ticket(RedLinkInfo *link)
 {
-    RedLinkInfo *link = (RedLinkInfo *)opaque;
     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",
@@ -1867,10 +1863,25 @@ static void reds_handle_ticket(void *opaque)
     if (password_size == -1) {
         spice_warning("failed to decrypt RSA encrypted password: %s",
                       ERR_error_string(ERR_get_error(), NULL));
-        goto error;
+        return NULL;
     }
     password[password_size] = '\0';
 
+    return password;
+}
+
+
+static void reds_handle_ticket(void *opaque)
+{
+    RedLinkInfo *link = (RedLinkInfo *)opaque;
+    char *password;
+    time_t ltime;
+
+    //todo: use monotonic time
+    time(&ltime);
+
+    password = reds_get_ticket(link);
+
     if (ticketing_enabled && !link->skip_auth) {
         int expired =  taTicket.expiration_time < ltime;
 
-- 
1.8.5.3

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]