qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v1] ui: correctly advance output buffer when writing SASL data
@ 2018-02-01 15:58 Daniel P. Berrangé
  2018-02-01 16:03 ` Eric Blake
  2018-02-01 16:25 ` Laszlo Ersek
  0 siblings, 2 replies; 4+ messages in thread
From: Daniel P. Berrangé @ 2018-02-01 15:58 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gerd Hoffmann, Laszlo Ersek, Daniel P. Berrangé

In this previous commit:

  commit 8f61f1c5a6bc06438a1172efa80bc7606594fa07
  Author: Daniel P. Berrange <berrange@redhat.com>
  Date:   Mon Dec 18 19:12:20 2017 +0000

    ui: track how much decoded data we consumed when doing SASL encoding

I attempted to fix a flaw with tracking how much data had actually been
processed when encoding with SASL. With that flaw, the VNC server could
mistakenly discard queued data that had not been sent.

The fix was not quite right though, because it merely decremented the
vs->output.offset value. This is effectively to discarding data from the
end of the pending output buffer. We actually need to discard data from
the start of the pending output buffer. We also want to free memory that
is no longer required. The correct way to handle this is to use the
buffer_advance() helper method instead of directly manipulating the
offset value.

Reported-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
 ui/vnc-auth-sasl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ui/vnc-auth-sasl.c b/ui/vnc-auth-sasl.c
index 74a5f513f2..fbccca8c8a 100644
--- a/ui/vnc-auth-sasl.c
+++ b/ui/vnc-auth-sasl.c
@@ -84,7 +84,7 @@ size_t vnc_client_write_sasl(VncState *vs)
         } else {
             vs->force_update_offset -= vs->sasl.encodedRawLength;
         }
-        vs->output.offset -= vs->sasl.encodedRawLength;
+        buffer_advance(&vs->output, vs->sasl.encodedRawLength);
         vs->sasl.encoded = NULL;
         vs->sasl.encodedOffset = vs->sasl.encodedLength = 0;
     }
-- 
2.14.3

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH v1] ui: correctly advance output buffer when writing SASL data
  2018-02-01 15:58 [Qemu-devel] [PATCH v1] ui: correctly advance output buffer when writing SASL data Daniel P. Berrangé
@ 2018-02-01 16:03 ` Eric Blake
  2018-02-02  6:49   ` Gerd Hoffmann
  2018-02-01 16:25 ` Laszlo Ersek
  1 sibling, 1 reply; 4+ messages in thread
From: Eric Blake @ 2018-02-01 16:03 UTC (permalink / raw)
  To: Daniel P. Berrangé, qemu-devel; +Cc: Laszlo Ersek, Gerd Hoffmann

[-- Attachment #1: Type: text/plain, Size: 1382 bytes --]

On 02/01/2018 09:58 AM, Daniel P. Berrangé wrote:
> In this previous commit:
> 
>   commit 8f61f1c5a6bc06438a1172efa80bc7606594fa07
>   Author: Daniel P. Berrange <berrange@redhat.com>
>   Date:   Mon Dec 18 19:12:20 2017 +0000
> 
>     ui: track how much decoded data we consumed when doing SASL encoding
> 
> I attempted to fix a flaw with tracking how much data had actually been
> processed when encoding with SASL. With that flaw, the VNC server could
> mistakenly discard queued data that had not been sent.
> 
> The fix was not quite right though, because it merely decremented the
> vs->output.offset value. This is effectively to discarding data from the

s/to //

> end of the pending output buffer. We actually need to discard data from
> the start of the pending output buffer. We also want to free memory that
> is no longer required. The correct way to handle this is to use the
> buffer_advance() helper method instead of directly manipulating the
> offset value.
> 
> Reported-by: Laszlo Ersek <lersek@redhat.com>
> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
> ---
>  ui/vnc-auth-sasl.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 619 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH v1] ui: correctly advance output buffer when writing SASL data
  2018-02-01 15:58 [Qemu-devel] [PATCH v1] ui: correctly advance output buffer when writing SASL data Daniel P. Berrangé
  2018-02-01 16:03 ` Eric Blake
@ 2018-02-01 16:25 ` Laszlo Ersek
  1 sibling, 0 replies; 4+ messages in thread
From: Laszlo Ersek @ 2018-02-01 16:25 UTC (permalink / raw)
  To: Daniel P. Berrangé, qemu-devel; +Cc: Gerd Hoffmann

On 02/01/18 16:58, Daniel P. Berrangé wrote:
> In this previous commit:
> 
>   commit 8f61f1c5a6bc06438a1172efa80bc7606594fa07
>   Author: Daniel P. Berrange <berrange@redhat.com>
>   Date:   Mon Dec 18 19:12:20 2017 +0000
> 
>     ui: track how much decoded data we consumed when doing SASL encoding
> 
> I attempted to fix a flaw with tracking how much data had actually been
> processed when encoding with SASL. With that flaw, the VNC server could
> mistakenly discard queued data that had not been sent.
> 
> The fix was not quite right though, because it merely decremented the
> vs->output.offset value. This is effectively to discarding data from the
> end of the pending output buffer. We actually need to discard data from
> the start of the pending output buffer. We also want to free memory that
> is no longer required. The correct way to handle this is to use the
> buffer_advance() helper method instead of directly manipulating the
> offset value.
> 
> Reported-by: Laszlo Ersek <lersek@redhat.com>
> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
> ---
>  ui/vnc-auth-sasl.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/ui/vnc-auth-sasl.c b/ui/vnc-auth-sasl.c
> index 74a5f513f2..fbccca8c8a 100644
> --- a/ui/vnc-auth-sasl.c
> +++ b/ui/vnc-auth-sasl.c
> @@ -84,7 +84,7 @@ size_t vnc_client_write_sasl(VncState *vs)
>          } else {
>              vs->force_update_offset -= vs->sasl.encodedRawLength;
>          }
> -        vs->output.offset -= vs->sasl.encodedRawLength;
> +        buffer_advance(&vs->output, vs->sasl.encodedRawLength);
>          vs->sasl.encoded = NULL;
>          vs->sasl.encodedOffset = vs->sasl.encodedLength = 0;
>      }
> 

With the typo pointed out by Eric fixed:

Reviewed-by: Laszlo Ersek <lersek@redhat.com>

Thank you!
Laszlo

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH v1] ui: correctly advance output buffer when writing SASL data
  2018-02-01 16:03 ` Eric Blake
@ 2018-02-02  6:49   ` Gerd Hoffmann
  0 siblings, 0 replies; 4+ messages in thread
From: Gerd Hoffmann @ 2018-02-02  6:49 UTC (permalink / raw)
  To: Eric Blake; +Cc: Daniel P. Berrangé, qemu-devel, Laszlo Ersek

On Thu, Feb 01, 2018 at 10:03:23AM -0600, Eric Blake wrote:
> On 02/01/2018 09:58 AM, Daniel P. Berrangé wrote:
> > In this previous commit:
> > 
> >   commit 8f61f1c5a6bc06438a1172efa80bc7606594fa07
> >   Author: Daniel P. Berrange <berrange@redhat.com>
> >   Date:   Mon Dec 18 19:12:20 2017 +0000
> > 
> >     ui: track how much decoded data we consumed when doing SASL encoding
> > 
> > I attempted to fix a flaw with tracking how much data had actually been
> > processed when encoding with SASL. With that flaw, the VNC server could
> > mistakenly discard queued data that had not been sent.
> > 
> > The fix was not quite right though, because it merely decremented the
> > vs->output.offset value. This is effectively to discarding data from the
> 
> s/to //

Patch queued, fix applied.

thanks,
  Gerd

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-02-02 16:21 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-02-01 15:58 [Qemu-devel] [PATCH v1] ui: correctly advance output buffer when writing SASL data Daniel P. Berrangé
2018-02-01 16:03 ` Eric Blake
2018-02-02  6:49   ` Gerd Hoffmann
2018-02-01 16:25 ` Laszlo Ersek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).