Skip to contentSkip to conversation

qemu-img: Fix segfault during rebase

PATCH Applied Kevin Wolf 2 participants 2 messages Feb 17, 2010 – Feb 19, 2010

lore
Share & tools
lore

Kevin Wolf

author
#0 lore raw

PATCH 1/1 qemu-img: Fix segfault during rebase

This fixes a possible read beyond the end of the temporary buffers used for comparing data in the old and the new backing file.

---
 qemu-img.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
qemu-img.c +1 -1
index 250d892..258dc62 100644
@@ -1225,7 +1225,7 @@ static int img_rebase(int argc, char **argv)
                 int pnum;
 
                 if (compare_sectors(buf_old + written * 512,
-                    buf_new + written * 512, n, &pnum))
+                    buf_new + written * 512, n - written, &pnum))
                 {
                     ret = bdrv_write(bs, sector + written,
                         buf_old + written * 512, pnum);
Signature · 1 line
1.6.6
#1 lore raw
Quoted 5 lines · Kevin Wolf

This fixes a possible read beyond the end of the temporary buffers used for comparing data in the old and the new backing file.

Applied. Thanks.

Regards,

Anthony Liguori

Quoted 18 lines
---
  qemu-img.c |    2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)
qemu-img.c +1 -1
index 250d892..258dc62 100644
@@ -1225,7 +1225,7 @@ static int img_rebase(int argc, char **argv)
                  int pnum;
 
                  if (compare_sectors(buf_old + written * 512,
-                    buf_new + written * 512, n,&pnum))
+                    buf_new + written * 512, n - written,&pnum))
                  {
                      ret = bdrv_write(bs, sector + written,
                          buf_old + written * 512, pnum);