Skip to contentSkip to conversation

ui: correctly advance output buffer when writing SASL data

PATCH In review Daniel P. Berrangé 4 participants 4 messages Feb 1, 2018 – Feb 2, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ui: correctly advance output buffer when writing SASL data

In this previous commit:

commit 8f61f1c5a6bc06438a1172efa80bc7606594fa07
Author: Daniel P. Berrange <[email protected]>
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.

---
 ui/vnc-auth-sasl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
ui/vnc-auth-sasl.c +1 -1
index 74a5f513f2..fbccca8c8a 100644
@@ -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;
     }
Signature · 1 line
2.14.3
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Daniel P. Berrangé

In this previous commit:

commit 8f61f1c5a6bc06438a1172efa80bc7606594fa07
Author: Daniel P. Berrange <[email protected]>
Date: Mon Dec 18 19:12:20 2017 +0000

Quoted 8 lines

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 //

Quoted 11 lines

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.

---
 ui/vnc-auth-sasl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org
#2 lore raw
Quoted 9 lines · Eric Blake
Quoted 8 lines · Daniel P. Berrangé

In this previous commit:

commit 8f61f1c5a6bc06438a1172efa80bc7606594fa07
Author: Daniel P. Berrange <[email protected]>
Date: Mon Dec 18 19:12:20 2017 +0000

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

Quoted 8 lines
Quoted 6 lines

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

Reviewed-by on v1 1/1
#3 lore raw
In reply to Daniel P. Berrangé
Quoted 32 lines · Daniel P. Berrangé

In this previous commit:

commit 8f61f1c5a6bc06438a1172efa80bc7606594fa07
Author: Daniel P. Berrange <[email protected]>
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.

---
 ui/vnc-auth-sasl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
ui/vnc-auth-sasl.c +0 -0
index 74a5f513f2..fbccca8c8a 100644

ui/vnc-auth-sasl.c size_t vnc_client_write_sasl(VncState *vs) · line 90

Quoted 8 lines
ui/vnc-auth-sasl.c +1 -1
@@ -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:

Thank you!
Laszlo