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

Christophe Fergeau cfergeau at redhat.com
Wed Nov 22 13:35:38 UTC 2017


On Wed, Nov 22, 2017 at 11:53:55AM +0000, Frediano Ziglio wrote:
> 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;
> +

You can drop the extra white-space after the "= ". I'd put the right
hand side member around () to make it more obvious it's a condition, but
we usually disagree on this kind of details ;)

Acked-by: Christophe Fergeau <cfergeau at redhat.com>

Christophe
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/spice-devel/attachments/20171122/e7d89bde/attachment.sig>


More information about the Spice-devel mailing list