]> xenbits.xensource.com Git - libvirt.git/commitdiff
virsh: avoid heap corruption leading to virsh abort
authorJim Meyering <meyering@redhat.com>
Mon, 7 May 2012 19:22:09 +0000 (21:22 +0200)
committerJim Meyering <meyering@redhat.com>
Mon, 7 May 2012 19:40:38 +0000 (21:40 +0200)
* tools/virsh.c (vshParseSnapshotDiskspec): Fix off-by-3 memmove
that would corrupt heap when parsing escaped --diskspec comma.
Bug introduced via commit v0.9.4-260-g35d52b5.

tools/virsh.c

index 1207ac9c50ad82adada5440e1a7957ae30370427..dd9292a1f08391146e4a8588042056cd55453e69 100644 (file)
@@ -16107,7 +16107,7 @@ vshParseSnapshotDiskspec(vshControl *ctl, virBufferPtr buf, const char *str)
     while ((tmp = strchr(tmp, ','))) {
         if (tmp[1] == ',') {
             /* Recognize ,, as an escape for a literal comma */
-            memmove(&tmp[1], &tmp[2], len - (tmp - spec) + 2);
+            memmove(&tmp[1], &tmp[2], len - (tmp - spec) - 2 + 1);
             len--;
             tmp++;
             continue;