All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel]  [PATCH] vnc-enc-tight: fix off-by-one bug
@ 2016-07-12  9:31 Herongguang (Stephen)
  2016-07-15 10:10 ` Gerd Hoffmann
  0 siblings, 1 reply; 2+ messages in thread
From: Herongguang (Stephen) @ 2016-07-12  9:31 UTC (permalink / raw)
  To: qemu-devel, kraxel, pbonzini, herongguang.he, weidong.huang,
	peter.huangpeng@huawei.com >> Huangpeng (Peter)

In tight_encode_indexed_rect32, buf(or src)’s size is count. In for loop,
the logic is supposed to be that i is an index into src, i should be
incremented when incrementing src.

This is broken when src is incremented but i is not before while loop,
resulting in off-by-one bug in while loop.

Signed-off-by: He Rongguang <herongguang.he@huawei.com>
---
  ui/vnc-enc-tight.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/ui/vnc-enc-tight.c b/ui/vnc-enc-tight.c
index e5cba0e..678c5df 100644
--- a/ui/vnc-enc-tight.c
+++ b/ui/vnc-enc-tight.c
@@ -461,9 +461,10 @@ static int tight_fill_palette(VncState *vs, int x, int y,
                                                                          \
          src = (uint##bpp##_t *) buf;                                    \
                                                                          \
-        for (i = 0; i < count; i++) {                                   \
+        for (i = 0; i < count; ) {                                      \
                                                                          \
              rgb = *src++;                                               \
+            i++;                                                        \
              rep = 0;                                                    \
              while (i < count && *src == rgb) {                          \
                  rep++, src++, i++;                                      \
-- 
1.8.3.4

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

* Re: [Qemu-devel] [PATCH] vnc-enc-tight: fix off-by-one bug
  2016-07-12  9:31 [Qemu-devel] [PATCH] vnc-enc-tight: fix off-by-one bug Herongguang (Stephen)
@ 2016-07-15 10:10 ` Gerd Hoffmann
  0 siblings, 0 replies; 2+ messages in thread
From: Gerd Hoffmann @ 2016-07-15 10:10 UTC (permalink / raw)
  To: Herongguang (Stephen)
  Cc: qemu-devel, pbonzini, weidong.huang,
	peter.huangpeng@huawei.com >> Huangpeng (Peter)

On Di, 2016-07-12 at 17:31 +0800, Herongguang (Stephen) wrote:
> In tight_encode_indexed_rect32, buf(or src)’s size is count. In for loop,
> the logic is supposed to be that i is an index into src, i should be
> incremented when incrementing src.
> 
> This is broken when src is incremented but i is not before while loop,
> resulting in off-by-one bug in while loop.
> 
> Signed-off-by: He Rongguang <herongguang.he@huawei.com>

Added to vnc queue.

Patch is whitespace mangled, had to use "patch --ignore-whitespace" to
get it applied.  Can you please use 'git send-email' to send patches in
the future?  That is the best way to avoid your mail client breaking
patches.

thanks,
  Gerd

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

end of thread, other threads:[~2016-07-15 10:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-12  9:31 [Qemu-devel] [PATCH] vnc-enc-tight: fix off-by-one bug Herongguang (Stephen)
2016-07-15 10:10 ` Gerd Hoffmann

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.